Game Development Reference
In-Depth Information
file, we close it. Do not forget to always close file readers and writers when you are
finished reading or writing, or you may not be able to open another file afterwards!
We now have completed the example belonging to this chapter. When you run
the example, you can see that all the levels are loaded. If you want to see all the
levels, you need to change the content of the 'levels_status.txt' file.
The curse of save games— Most games contain a mechanism that allows sav-
ing of the player's progress. This is normally used in three ways: to continue
playing later, to return to a previous save point when you fail later on in the
game, or to exploit alternative strategies or story-lines. Even though this all
sounds very reasonable, it also introduces lots of problems and when you de-
sign a game you carefully have to consider when (and how) to allow the player
to save and load the game state.
For example, in older first person shooters, all enemies were at fixed loca-
tions in the game world. A common strategy among players became to save
a game, then just run into a room to see where the enemies were (which led
to instant death), then loading the save game and, with the information about
the location of the enemies, carefully clean out the room. This made the game
a lot easier to play, but it was definitely not the intention of the creators. This
can partially be remedied by making it difficult to save a game or to load a
saved game.
Other games only allow saves at particular save points. Some even make
reaching a save point part of the challenge. But this can lead to frustration
because the player may have to replay sections of the game over and over
again because there is just one very difficult spot. The most interesting games
are the ones where you never have to return to save points because you never
really fail, but this is extremely difficult to design.
So think carefully about your saving mechanism. When will you allow
saves? How many different saves do you allow? How does the saving work?
How do you load a saved game? Does it cost something to save or load a
game? All these decisions will influence the gameplay and the player satis-
faction.
22.9 What You Have Learned
In this chapter, you have learned:
how to read from and write to text files;
how to create a tile-based game world;
how to retrieve and store level status using a file.
Search WWH ::




Custom Search