HTML and CSS Reference
In-Depth Information
In checkCollisions() , we need to pass the type parameter to the createExplode() func-
tion so the type can be assigned to the particles in the explosion. Here is an example of a
createExplode() function call used for a rock instance:
createExplode ( tempRock . x + tempRock . halfWidth , tempRock . y + tempRock . halfHeight ,
10 , tempRock . scale );
We pass the tempRock.scale as the final parameter because we are using the rock's scale as
the type .
For a saucer:
createExplode ( tempSaucer . x + tempSaucer . halfWidth ,
tempSaucer . y + tempSaucer . halfHeight , 10 , 0 );
For the saucers and the player, we pass a number literal into the createExplode() function.
In the saucer's case, we pass in a 0 . For the player ship, we pass in a 4 :
createExplode ( player . x + player . halfWidth , player . y + player . halfWidth , 50 , 4 );
Note that the createExplode() function call for the player is in the playerDie() function,
which is called from checkCollisions() .
NOTE
After we discuss adding sound and a particle pool to this game, we present the entire set of code
( Example A-2 ) , replacing the Geo Blaster Basic code. There is no need to make the changes to the
individual functions.
Search WWH ::




Custom Search