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 OnUpdate method

During the OnUpdate method, we will do different things depending on the gameMode field. If the mode is gmPlay, we will update all objects and do collision checks. In other modes, we mostly check for certain keys that are hit on the keyboard to switch the game into a different mode.

  1. Add a Select statement with the gameMode field as a parameter.
    Method OnUpdate:Int()
    Local d:Float = Float(eng.CalcDeltaTime())/60.0
    If isSuspended = False Then
    Select gameMode
    
  2. Check against the gmPlay constant.
    Case gmPlay
    eng.Update(Float(d))
    

    The call to the Update method of the engine is now part of the gmPlay segment.

  3. Now, check for any collisions happening on the game layer. The response for this will be detailed inside ...

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