Page 1 of 1

How do you add a High Score to your game?

PostPosted: Mon Aug 23, 2010 1:51 am
by zxcvbnm
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.

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

PostPosted: Mon Aug 23, 2010 2:14 am
by DilloDude
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.

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

PostPosted: Mon Aug 23, 2010 8:26 am
by zxcvbnm
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?