Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on my first game, and are looking into the option to save a number of game state settings.

One of the things I want to save is the high scores, this will contain a list of the 10 players that scored the highest.

I have been looking into this for a while, and was wondering what the best way for this is.

While being ingame I will have a list of high scores comprised of Player, Score, Level. This of course needs to be updated each time the score has been beaten, but it also needs to be saved somewhere where it won't be reset the whole time.

I would think this kind of information should be saved into a file (either xml or comma separated values).

The problem I'm facing is what to do on the initial set up (I would like to have some fake values in the high scores table), however if I add that to the file how do I know that the scores in there are the initial set up ones, or the real ones? Once the player has a endgame for the first time, these fake scores should not being shown anymore.

However the player can also reset the scores, and at that point I would like to have the fake scores shown again.

So my question is what is the best way of setting this up? Do I keep 2 files, one with the real scores, other with fake ones? or do I keep the fake ones in a list inside the game and when the file with high scores can't be found I use that list?

share|improve this question
    
Why don't you initialize your high score file with zero score entires? Why do you need fake scores? –  Petr Abdulin Apr 20 '12 at 9:24
add comment

1 Answer

Usual logic for such situations is some thing like (pseudocode):

// at game init
if(file_not_found)
  scores_list = create_default()
else
  scores_list = load_from_file()

// use scores in the game

// at shutdown
save_scores_file()

where create_default() will create initial scores file. It can be empty, zero_scored or some predefined fake scores, whatever.

share|improve this answer
    
I would do this, but slightly different. Instead of create_default() I would load_default(), obviously just a name change but I'm implying that the "fake" scores would be in a second file. When the player clears their top score, the player made file is removed and it defaults to the "fake" scores file. Keeps most of the other code the same, without needing to update code if you want to change the "fake" scores. –  Byte56 Apr 20 '12 at 14:23
    
@Byte56 I usually tend to minimize number of files on which program depends (i.e. it won't crush if default score file is deleted). However in case of games this is of course not so important, so you are right on that. –  Petr Abdulin Apr 20 '12 at 16:12
    
Why do you need to know if the scores are fake or not. Providing an initial set of scores also gives the player something to aim for. If you say the best score is 1000 then that can act as a way of informing the player that it's possible to get more than 1000 points. –  OriginalDaemon Apr 20 '12 at 23:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.