HTML and CSS Reference
In-Depth Information
update()
Is called from
GAME_STATE_PLAY_LEVEL
. It in turn calls the
update()
function for each
individual display object array.
Individual display object
update()
update()
functions
The unique functions listed below update each different type of display object. These
functions(withtheexceptionof
updatePlayer()
)willloopthroughtherespectivear-
ray of objects associated with its type of display object and update the
x
and
y
values
with
dx
and
dy
values. The
updateSaucer()
function contains the logic necessary to
check whether to create a new saucer and whether any current saucers on the screen
should fire a missile at the player.
▪
updatePlayer()
▪
updatePlayerMissiles()
▪
updateRocks()
▪
updateSaucers()
▪
updateSaucerMissiles()
▪
updateParticles()
render()
Is called from
GAME_STATE_PLAY_LEVEL
. It in turn calls the
render()
function for each
individual display object array.
Individual display object
render()
render()
functions
Like the
update()
functions, the unique functions listed below render each different
type of display object. Again, with the exception of the
renderPlayer()
object (be-
cause there is only a single player ship), each of these functions will loop through the
array of objects associated with its type and draw them to the game screen. As we saw
whendrawingtheplayershipearlierinthischapter,wewilldraweachobjectbymov-
ingandtranslatingthecanvastothepointatwhichwewanttodrawourlogicalobject.
Wewillthentransformourobject(ifnecessary)andpaintthepathstothegamescreen.
▪
renderPlayer()
▪
renderPlayerMissiles()