HTML and CSS Reference
In-Depth Information
•
renderSaucers()
•
renderSaucerMissiles()
•
renderParticles()
checkCollisions()
Loops through the individual game display objects and checks them for collisions.
See the section
“Applying Collision Detection” on page 417
for a detailed discus-
sion of this topic.
firePlayerMissile()
Creates a
playerMissile
object at the center of the player ship and fires it in the
direction the player ship is facing.
fireSaucerMissile()
Creates a
saucerMissile
object at the center of the saucer and fires it in the direction
of the player ship.
playerDie()
Creates an explosion for the player by calling
createExplode()
, as well as changing
the game application state to
GAME_STATE_PLAYER_DIE
.
createExplode()
Accepts in the location for the explosion to start and the number of particles for
the explosion.
boundingBoxCollide()
Determines whether the rectangular box that encompasses an object's width and
height is overlapping the bounding box of another object. It takes in two logical
display objects as parameters, and returns
true
if they are overlapping and
false
if they are not. See the section
“Applying Collision Detection” on page 417
for
details on this function.
splitRock()
Accepts in the scale and
x
and
y
starting points for two new rocks that will be
created if a large or medium rock is destroyed.
addToScore()
Accepts in a value to add to the player's score.
Geo Blaster Global Game Variables
Now let's look at the entire set of game application scope variables needed for our game.
Variables that control screen flow
These variables will be used when the title and “Game Over” screens first appear.
They will be set to
true
once the screen is drawn. When these variables are
true
,
the screens will look for the space bar to be pressed before moving on to the next
application state: