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 — finalizing the OnUpdate method

The OnUpdate event is the place to update all game objects and control the flow of the game in general. You do everything in the method line-by-line and with hundreds of statements. However, we took the approach with building a lot of helper methods, which will now be called inside this method:

  1. Inside the OnUpdate method, store the result of a call to the method GetDeltaTime in the local variable d.
    Method OnUpdate:Int()
    Local d:Int = GetDeltaTime()
    
  2. Check with an If statement, whether the field isSuspended is FALSE.
    If isSuspended = False Then
    
  3. Add a Select statement with the field gameMode. Then, insert the Case statement for the constant gmPlay.
    Select gameMode
    Case gmPlay
    
  4. Now, call the Update method ...

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