This site requires JavaScript, please enable it in your browser!
Greenfoot back
GreenGoo
GreenGoo wrote ...

2013/5/18

High Score Help

GreenGoo GreenGoo

2013/5/18

#
In my game Squares (http://www.greenfoot.org/scenarios/8332), I want to implement a score board. I've used Busch2207's HighScore scenario (http://www.greenfoot.org/scenarios/8385) but I can't make it work. I've uploaded the code for my game so that people can look at it. Any help would be greatly appreciated.
Busch2207 Busch2207

2013/5/18

#
First thing is the problem with the mouse, leaving the screen, just write:
        if(mouse!=null)
            setLocation(mouse.getX(), mouse.getY());
instead of only 'setLocation(mouse.getX(), mouse.getY());' in your Player-class! :) To implement the HighScore, you first have to save the score! This you can do, when you add the 'Game Over'! You can save the score by writing:
            UserInfo ui_My=UserInfo.getMyInfo();
            if(ui_My!=null && ui_My.getScore()<score)
            {
                ui_My.setScore(score);
                ui_My.store();
            }
To add the HighScore, you just write:
            addObject(new HighScore(...),x-Coordinate,y-Coordinate);
The easiest contructor of my HighScore class would be:
new HighScore(int width, int height, int ListElements,boolean top)
to have a better preview over the HighScore-constructors, you can take a look at the documentation of this class. If you need help with the constructors, just ask. ;)
Busch2207 Busch2207

2013/5/19

#
If you want two Highscores. One with the Top Players and one with the players near the current Player, you would have to add two of this highscores, of course. :)
You need to login to post a reply.