Saving Game States

[ LiB ]

New programmers always wonder how to save their game. In Flash, you can only save your game on the Internet because Flash cannot write out information to individual files that can be stored locally; instead, Flash has to send information to a script that can then, in turn , write and save the information that Flash sent to it in an external file. It's not as difficult as it seems once you start to break down what your game really consists of.

Think about itwhat's one thing your game can't function without? That's right, informa tion . And where is this information stored? Yes, in variables. If you grab and organize all the variables in your game, you can easily put them in a small database and retrieve them at a later time. This would, thus, save the game state.



There isn't a demo for this section because you are going to write the code. How does it feel to be let loose?

Let's say you had a side-scrolling game. What are some of the variables that you would constantly be updating to keep track of the game? Here is my list. You can add to it if you wish.

  • Player score

  • Player energy

  • Player level

  • Player weapons

  • Enemies alive

If the player decides to save the game at any point in time, these variables should be recorded. When they're retrieved, the game should continue from where he left off. Figure 13.8 shows what I'm talking about.

Figure 13.8. Saving game states


[ LiB ]

Game Development with ActionScript
Game Development with ActionScript
ISBN: 1592001106
EAN: 2147483647
Year: 2004
Pages: 162
Authors: Lewis Moronta © 2008-2017.
If you may any questions please contact us: