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?

  • \$\begingroup\$ Why don't you initialize your high score file with zero score entires? Why do you need fake scores? \$\endgroup\$ Apr 20, 2012 at 9:24

1 Answer 1


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

// at game init
  scores_list = create_default()
  scores_list = load_from_file()

// use scores in the game

// at shutdown

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

  • \$\begingroup\$ 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. \$\endgroup\$
    – House
    Apr 20, 2012 at 14:23
  • \$\begingroup\$ @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. \$\endgroup\$ Apr 20, 2012 at 16:12
  • \$\begingroup\$ 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. \$\endgroup\$ Apr 20, 2012 at 23:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .