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 tiles

When we create the set of tiles, we want to place them inside a grid of three lines with five tiles in each. For this, we will create a new method:

  1. Add the method CreateTitles to the game class.
    Method CreateTiles:Int()
    
  2. To reset the tile count, which is needed to determine a new level, we set the variable TileCount to 0.
    TileCount = 0
    
  3. Now create two FOR loops, one for the y position factor from 1 to 3 and one for the x position factor from one to five.
    For Local y:Int = 1 To 3
    For Local x:Int = 1 To 5
    
  4. Create a local object through CreateImage. The position will be calculated as one-sixth of the canvas width times the x factor, and 80 times the y factor, plus 100. This will place the tiles equally over the top part ...

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