How do you add a High Score to your game?

Non-platform specific questions.

How do you add a High Score to your game?

Postby zxcvbnm » Mon Aug 23, 2010 1:51 am

Hi ladies and gentlemen. I have a simple question to ask. If I have a game that has a score, how will I add a high score to the game?
I need the high score to be saved in the game so players can compete with themselves or others. That you for any help in that matter kind people.
zxcvbnm
 
Posts: 248
Joined: Sun Aug 22, 2010 7:57 pm
Score: 10 Give a positive score

Re: How do you add a High Score to your game?

Postby DilloDude » Mon Aug 23, 2010 2:14 am

On the event where you increase the score, check if it's greater than the highscore, and if it is, set the highscore to the score value. Then you can use saveVars, or write your own save method (using fwrite or something awesome like that) to save it.
Code: Select all
score += 10; // increase the score
if (score > highScore)
{
    highScore = score;
    //save variable here
}

Then just load the variables when the game starts.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: How do you add a High Score to your game?

Postby zxcvbnm » Mon Aug 23, 2010 8:26 am

Thank you! You mentioned the save feature which I am interested in. How exactly do you use fwrite to save a game or high score?
Check out Momo AlienStarcatcher , featured in apples new and noteworthy and has 5 star reviews!!!
http://itunes.apple.com/us/app/momo-ali ... 61779?mt=8
zxcvbnm
 
Posts: 248
Joined: Sun Aug 22, 2010 7:57 pm
Score: 10 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest