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 — creating the "game over" screen

In the next method, a screen will be created and will display Game Over and the score that the player had reached.

  1. Insert the method CreateGameOverScreen into the game class.
    Method CreateGameOverScreen:Int ()
    
  2. Set the default layer to layerGameOver.
    eng.SetDefaultLayer(layerGameOver)
    
  3. Create a blue box.
    Local b := eng.CreateBox(cw/1.5,ch/4,cw/2,ch/2)
    b.SetColor(0,0,255)
    
  4. Add a text object that will display the text GAME OVER.
    Local tx1 := eng.CreateText(font1,"**** GAME OVER ****",cw/2,ch/2-30,3)
    
  5. To display the score, add another text object (txtFinalScore).
    txtFinalScore = eng.CreateText(font1,"SCORE: 000000",cw/2,ch/2+30,3)
    Return 0
    End
    

What just happened?

When this method is called later on, it will ...

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