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

2014/4/3

How to make a high score system

qwertyuiop qwertyuiop

2014/4/3

#
I have almost finished my game but I would like a way to display the high score as well, however I have no idea how to do it and don't know where to start. Any help would be appreciated, thanks.
AIMrOrange AIMrOrange

2014/4/3

#
I also tried to implement this in my Scenario "Space Invaders" but after some hours i decided to set this as a goal in the later future^^ All I know so far is: There is a UserInfo class in greenfoot, you can just use it like GreenfootImage or sounds etc. You need set the highscore at some point with "setScore(score)" and get it back it in the grafical animation where you want to have it shown with "getScore()". First of all you have to create a UserInfo object, i.e. UserInfo myInfo = UserInfo.getMyInfo(); I managed to get the reached score shown in the highscore menu after the game, but I failed and only storing a new one if newscore > highscore... For more complex things like a top ten list for example, you will need to inform yourself, i cant help you with that^^ (Im still very new to Greenfoot) I hope this will help you ;)
qwertyuiop qwertyuiop

2014/4/3

#
Yeah, I understand a bit more the task at hand, but it still seems a bit complex. Thanks for the help though.
erdelf erdelf

2014/4/3

#
there is a scoreboard class, you can import in greenfoot Edit -> Import class just add it like a normal actor and it display's the top ten on the left side, and your position on the right side to save a score you could write something like this
1
2
3
4
5
6
7
if (UserInfo.isStorageAvailable()) {
    UserInfo myInfo = UserInfo.getMyInfo();
    if (newScore > myInfo.getScore()) {
        myInfo.setScore(newScore);
        myInfo.store();  // write back to server
    }
}
replace newScore with the score in your scenario
AIMrOrange AIMrOrange

2014/4/4

#
Wow dude, thank you so much :P Im surprised how simple it is^^ Awesome!
You need to login to post a reply.