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 data structure

To store the data, we will enhance the game class with some fields and constants, as follows:

  1. First, add two text objects that will display the scores of the player and the computer.
    Class game Extends App
    Field eng:engine
    Field isSuspended:Bool = False
    Field txtScore:ftObject
    Field txtScoreC:ftObject
    
  2. Next, add two text objects that will display if the player wins or loses.
    Field txtYouWin:ftObject
    Field txtYouLoose:ftObject
    
  3. The player plane and the enemy plane will be stored in separate objects.
    Field player:ftObject
    Field enemy:ftObject
    
  4. The game font also has to be stored.
    Field font1:ftFont
    
  5. Now, add five layers for the background, the game and clouds, and also the information and the title screen.

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