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 — acting on the different game modes

The last thing to add is the need to act to the game modes. We have three modes:

  • 0=Start of game
  • 1=Gameplay
  • 2=GameOver

We want to direct and inform the player about what mode the game is in and how they can start it. Then if the victory conditions are achieved, we want to give a visual response.

  1. The first mode is bound to a new method that we will create now. Create a new method called StartGame.
    Method StartGame:Int()
    
  2. We want to print a message only once; that is why we need the field modeMessage. If it is 0, then we can print this message. If we don't use such an approach, the message will be printed every time we call this method.
    If modeMEssage = 0 Then
    
  3. Now set messageMode to 1 and print a message: ...

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