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 — detailing the Update process

We have have three game modes. Two of them, gmMenu and gmGameOver, are modes where some kind of menu or text is displayed. The third mode, gmPlay, is for rendering and updating the actual game play.

  1. Add a Select statement to the OnUpdate method.
    Method OnUpdate:Int()
    Select gameMode
    
  2. Depending on whether gameMode is gmMenu or gmOver, we will call a new method UpdateMenu.
    Case gmMenu, gmGameOver
    UpdateMenu()
    
  3. When gameMode is equal to gmPlay, call another new method called UpdateGame.
    Case gmPlay
    UpdateGame()
    
  4. Close the Select statement.
    End
    End
    
  5. Now, add the bodies of the formerly mentioned methods, UpdateMenu and UpdateGame. Inside UpdateMenu, we will also add an IF statement to act differently, depending ...

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