HTML and CSS Reference
In-Depth Information
gameStateTitle()
Displays the title screen text and waits for the space bar to be pressed before the
game starts.
gameStateNewGame()
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 .
gameStateNewLevel()
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
details.
gameStatePlayerStart()
Fades the player graphic onto the screen from 0 alpha to 1 . Once this is complete,
level play will start.
gameStatePlayLevel()
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.
gameStatePlayerDie()
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
GAME_STATE_PLAYER_START state.
gameStateGameOver()
Displays the “Game Over” screen, and starts a new game when the space bar is
pressed.
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:
resetPlayer()
Resets the player to the center of the game screen and readies it for game play.
checkForExtraShip()
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.
checkForEndOfLevel()
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.
fillBackground()
Fills the canvas with the background color on each frame tick.
Search WWH ::




Custom Search