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

The update process will determine the current delta time, reset the collision markers, and do the collision checks. It also will check the buttons of the game pad.

  1. The first change is to add a Select statement inside the If statement that depends on the field gameMode.
    Method OnUpdate:Int()
    Local d:Float = Float(eng.CalcDeltaTime())/60.0
    If isSuspended = False then
    Select gameMode
    
  2. Check whether the game mode is equal to gmPlay.
    Case gmPlay
    
  3. Reset the number of crates that are on a target.
    OnTarget = 0
    
  4. Also, reset whether the player's collision zones hit a wall or a crate.
    hitWall = False
    hitWall2 = False
    hitCrate = Null
    hitCrate2 = Null
    
  5. Perform a collision check on the game layer.
    eng.CollisionCheck(layerGame) ...

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