HTML and CSS Reference
In-Depth Information
player.destinationX
The final x location for the 32×32 player object while it is moving to a new tile. It
represents the top-left corner x location for this new location. During the player
movement and animation phase of the game, this value determines when the player
has arrived at its new x-axis location.
player.destinationY
The final y location for the 32×32 player object while it is moving to a new tile. It
represents the top-left corner y location for this new location. During the player
movement and animation phase of the game, this value determines when the player
has arrived at its new y-axis location.
player.x
The current x location of the top-left corner of the 32×32 player object.
player.y
The current y location of the top-left corner of the 32×32 player object.
player.dx
The player's change in x direction on each frame tick while it is animating. This
will be -1 , 0 , or 1 , depending on the direction in which the player is moving.
player.dy
The player's change in y direction on each frame tick while it is animating. This
will be -1 , 0 , or 1 , depending on the direction in which the player is moving.
player.hit
Set to true when the player moves to a new square that is occupied by an enemy
tank or a wall.
player.dead
When player.hit is true , it will be replaced on the playField by an explosion sprite.
With dead set to true , it will not be rendered to the game screen.
player.win
Set to true if the player collects the goal object.
The enemy and the player share many of the same attributes, as they both use the same
type of calculations to move about the grid. Now let's examine how the enemy object
is constructed.
The Enemy
Each enemy object will have its own set of attributes that are very similar to those of the
player. Like the player, each enemy will be an object instance.
Here is the code from the createPlayField() function that sets up the attributes for a
new enemy object:
EnemyLocationFound = true;
var tempEnemy = {};
tempEnemy.row = randRow;
Search WWH ::




Custom Search