HTML and CSS Reference
In-Depth Information
newParticle.lifeCtr = 0;
newParticle.x = x;
newParticle.y = y;
Level Knobs
Even though we never show the level number to the game player, we are adjusting the
difficulty every time a screen of rocks is cleared. We do this by increasing the level
variable by 1 and then recalculating these values before the level begins. We refer to the
variance in level difficulty as knobs , which refers to dials or switches. Here are the
variables we will use for these knobs:
level+3
Number of rocks
levelRockMaxSpeedAdjust = level*.25;
Rock max speed
levelSaucerMax = 1+Math.floor(level/10);
Number of simultaneous saucers
levelSaucerOccurrenceRate = 10+3*level;
Percent chance a saucer will appear
levelSaucerSpeed = 1+.5*level;
Saucer speed
levelSaucerFireDelay = 120-10*level;
Delay between saucer missiles
levelSaucerFireRate = 20+3*level;
Percent chance a saucer will fire at the player
levelSaucerMissileSpeed = 1+.2*level;
Speed of saucer missiles
Level and Game End
We need to check for game and level end so we can transition to either a new game or
to the next level.
Level end
We will check for level end on each frame tick. The function to do so will look like this:
function checkForEndOfLevel(){
if (rocks.length==0) {
switchGameState(GAME_STATE_NEW_LEVEL);
}
}
Once the rocks array length is 0 , we switch the state to GAME_STATE_NEW_LEVEL .
Search WWH ::




Custom Search