• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Game over!

When does the game end? There are three rounds (one for each missile launcher), and each round ends when at least one of the aliens finally hits the ground. The stepFrame handler in the alien parent script tests for that condition by calling the checkEndGame handler (also in the alien parent script).

Almost the entire handler consists of an if statement that is executed only if an alien has landed. The first task is to play the endgame sound. I had some timing problems here, since a whole row of aliens reaches the bottom at the same time, and any one of them can start the endgame sound playing. I first check the sound's status (a value of zero means nothing is queued or playing). The new sound commands are a bit temperamental for timing, and a new addition to the queue may get played along with the current sound, or may end up as the first sound for the next play command. Checking the status can help prevent such problems.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint