HTML and CSS Reference
In-Depth Information
When all the enemy tanks have completed their moves, the game state is changed to
the GAME_STATE_EVALUATE_ENEMY_MOVE state.
GAME_STATE_EVALUATE_ENEMY_MOVE
Like GAME_STATE_EVALUATE_PLAYER_MOVE , this state looks at the location of each tank to
determine which ones need to be destroyed.
If a tank occupies the same tile as the player, a wall, or another tank, the tank is “to be
destroyed”. If the player and enemy tank occupy the same tile, the player is also “to be
destroyed”. This “to be destroyed” state is set by placing true in the hit attribute of
the enemy tank or the player.
The game is then moved to the GAME_STATE_EVALUATE_OUTCOME state.
GAME_STATE_EVALUATE_OUTCOME
This function looks at each of the enemy tanks and the player tank to determine which
have a hit attribute set to true . If any do, that tank's dead attribute is set to true , and
an explosion is created by calling createExplode() and passing in the object instance
(player or enemy tank). In the case of the enemy, a dead enemy is also removed from
the enemy array.
The GAME_STATE_ANIMATE_EXPLODE state is called next.
GAME_STATE_ANIMATE_EXPLODE
If the explosions array length is greater than 0 , this function loops through each instance
and animates them using the explodeTiles array. Each explosion instance is removed
from the explosions array after it finishes its animation. When the explosions array
length is 0 , the game moves to the GAME_STATE_CHECK_FOR_GAME_OVER state.
GAME_STATE_CHECK_FOR_GAME_OVER
This state will first check to see whether the player is dead, and then check to see
whether he has won. That means that the player cannot win if an enemy tank makes it
to the goal on the same try as the player.
If the player has lost, the state changes to GAME_STATE_PLAYER_LOSE ; if the player has
won, it moves to the GAME_STATE_PLAYER_WIN state. If neither of those has occurred, the
game is set to GAME_STATE_WAIT_FOR_PLAYER_MOVE . This starts the game loop iteration
over, and the player begins her next turn.
Search WWH ::




Custom Search