HTML and CSS Reference
The Player Object
The player objectcontainsmanyofthevariablesweencounteredearlierinthischapterwhen
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
lated on each frame tick in multiple locations inside the code. The missileFrameDelay vari-
able 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.