Re: A89: About saving integers in C.


[Prev][Next][Index][Thread]

Re: A89: About saving integers in C.




make HighScore a static variable. An example is:

static int HighScore=0;

You MUST initialize all static variables. Keep in mind that this value is 
only the initial value for the first time the program is run. The next time 
it is run it will contain the last value stored to HighScore (ie. the new 
highscore). This will only work if the user doesn't have your game archived. 
I would recommend using a TIOS variable to store the highscore, but this is a 
simple way to do it and the way I think you are looking for.

- Josh

<< For saving a high score in C, how would you work that?

So far I have...

    if (Score > HighScore) {
        ClearPlanes();
        Print(20,20,"YOU ACHIEVED BEST SCORE!",A_REPLACE);
        HighScore = Score;
        sprintf (TextBuffer, "%d", HighScore);
        Print(50, 27, TextBuffer, A_REPLACE);        
        ngetchx();    
    }

Now it will replace the value of high score, but it won't write it to
memory,
because next time I run the program, it says BEST SCORE: 0. >>




Follow-Ups: