HTML and CSS Reference
In-Depth Information
Displays the title screen text and waits for the space bar to be pressed before the
game starts.
Sets up all the defaults for a new game. All of the arrays for holding display objects
are reinitialized—the game level is reset to 0 , and the game score is set to 0 .
Increases the level value by one, and then sets the “game knob” values to control
the level difficulty. See the upcoming section “Level Knobs” on page 415 for
Fades the player graphic onto the screen from 0 alpha to 1 . Once this is complete,
level play will start.
Controls the play of the game level. It calls the update() and render() functions,
as well as the functions for evaluating keyboard input for player ship control.
Starts up an explosion at the location where the player ship was when it was hit by
a rock, saucer, or saucer missile. Once the explosion is complete (all particles in
the explosion have exhausted their individual life values), it sets the move to the
Displays the “Game Over” screen, and starts a new game when the space bar is
Game application functions
Aside from the game application state functions, there are a number of functions we
need for the game to run. Each state function will call these functions as needed:
Resets the player to the center of the game screen and readies it for game play.
Checks to see whether the player should be awarded an extra ship. See the section
“Awarding the Player Extra Ships” on page 416 for details on this algorithm.
Checks to see whether all the rocks have been destroyed on a given level and, if so,
starts up a new level. See the section “Level and Game End” on page 415 for details
on this algorithm.
Fills the canvas with the background color on each frame tick.
Search WWH ::

Custom Search