Game Development Reference
In-Depth Information
Figure 21-2. One of the levels in the Penguin Pairs game
Maintaining the Player's Progress
To complete this chapter, this section shows you a nice way to keep track of the player's progress
over different sessions. You want the game to remember where the player was when they last played
the game. There are several ways to do this. One way would be to let the player do this job and
simply open all the levels to the player by default. This is a solution, but it doesn't really motivate
the player to solve each level in sequence. Another way would be to use a database on a server
that could be accessed by a JavaScript application. You could then store player information on that
server and keep track of the player that way. This would work, but it's also not ideal because you
would need to have a server up and running in addition to your JavaScript application. The third
option is to use a feature introduced in HTML5 called HTML5 web storage .
HTML5 web storage provides a way to store information in two different ways, using two different
variables. If you assign something to the variable code.sessionStorage , this information is
retained until the tab where the application is running is closed. If you assign a value to the variable
 
Search WWH ::




Custom Search