O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — modifying the menu update process

  1. Head to the UpdateMenu method and add the following lines:
    If gameMode = gmMenu
    'we will add code here later
    
  2. Check if the P key was hit.
    If KeyHit(KEY_P) Then
    
  3. Set game mode to gmPlay, and also seed the random number generator with the current time (in milliseconds) from when this game is active.
    gameMode = gmPlay
    'Set random number generator
    Seed = Millisecs()
    Endif
    Else
    'Code that runs when gameMode = gmGameOver
    
  4. Check if the R key is hit after one game is over.
    If KeyHit(KEY_R) Then
    
  5. Remove all cities and rocket launchers.
    RemoveCities()
    RemoveLaunchers()
    
  6. Set up the game again, and set the game mode to gmPlay.
    SetupGame()
    gameMode = gmPlay
    Endif
    Endif
    Return True
    End
    

What just happened?

Good, now we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required