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

  1. Head over to the OnUpdate method and add a Select statement with the gameMode as a parameter.
    Method OnUpdate:Int()
    Select gameMode
    
  2. When the game mode is gmPlay, update the engine with the deltaTime divided by 60 as a speed parameter.
    Case gmPlay
    eng.Update(Float(UpdateGameTime())/60.0)
    
  3. Do a collision check only on the layerGame layer.
    eng.CollisionCheck(layerGame)
    
  4. Update the info text objects.
    UpdateInfoText()
    
  5. When the game mode is gmMenu or gmGameOver.
    Case gmMenu, gmGameOver
    

    If the P key was hit, then start a new game.

    If KeyHit(KEY_P) Then
    StartNewGame()
    Endif
    

    If the H key was hit, then show the high score list.

    If KeyHit(KEY_H) Then
    ShowScoreList()
    Endif
    
  6. When the game mode is gmScoreList.
    Case gmScoreList ...

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