HTML and CSS Reference
In-Depth Information
Level-specific variables
The level-specific variables handle the difficulty settings when the game level in-
creases. See the section “Level Knobs” on page 415 for more details on how these
are used:
var levelRockMaxSpeedAdjust = 1;
var levelSaucerMax = 1;
var levelSaucerOccurrenceRate = 25
var levelSaucerSpeed = 1;
var levelSaucerFireDelay = 300;
var levelSaucerFireRate = 30;
var levelSaucerMissileSpeed = 1;
The player Object
The player object contains many of the variables we encountered earlier in this chapter
when we discussed animating, rotating, and moving the player ship about the game
screen. We have also added in three new variables that you have not seen before:
player.maxVelocity = 5;
player.width = 20;
player.height = 20;
player.halfWidth = 10;
player.halfHeight = 10;
player.rotationalVelocity = 5
player.thrustAcceleration = .05;
player.missileFrameDelay = 5;
player.thrust = false;
The new variables are halfWidth , halfHeight , and missileFrameDelay . halfWidth and
halfHeight simply store half the width and half the height values, so these need not be
calculated on each frame tick in multiple locations inside the code. The missileFrame
Delay variable contains the number of frame ticks the game will count between firing
player missiles. This way, the player cannot simply fire a steady stream of ordnance
and destroy everything with little difficulty.
The player.thrust variable will be set to true when the player presses the up key.
Geo Blaster Game Algorithms
The game source code covers a lot of ground that we did not touch on earlier in this
chapter. Let's discuss some of those topics now; the rest will be covered in detail in
Chapter 9 .
Arrays of Logical Display Objects
We have used arrays to hold all our logical display objects, and we have an array for
each type of object ( rocks , saucers , playerMissiles , saucerMissiles , and particles ).
Search WWH ::




Custom Search