Game Development Reference
In-Depth Information
The game
Two new features were added to this second version of the game. First, we now keep
track of the highest score achieved by a player, saving it through local storage. Even
if the player closes the browser application, or turns off the computer, that value will
still be safely stored in the player's hard drive, and will be loaded when the game
starts again. Second, we use session storage to save the game state every time
the player eats a fruit in the game, and whenever the player kills the snake. This is
used as an extra touch of awesomeness, where after the player loses, we display a
snapshot of all the individual level ups the player achieved in that game, as well as
a snapshot of when the player hit a wall or run the snake into itself, as shown in the
following screenshot:
At the end of each game, an image is shown of each moment when the player ac-
quired a level up, as well as a snapshot of when the player eventually died. This im-
ages are created through the canvas API (calling the toDataURL function), and the
Search WWH ::




Custom Search