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 — refilling the tile map

  1. Create a new method called FillTiles inside the game class.
    Method FillTiles:Int()
    
  2. Add two local variables with the type BOOL. They will be used to determine if a row was filled.
    Local filled:Bool = False
    Local filled2:Bool = False
    
  3. Start two FOR loops for the rows and the columns.
    For Local r:Int = rows To 1 Step -1
    For Local c:Int = columns To 1 Step -1
    
  4. Set filled2 to False and check if the tile map is in the initial position (= -1).
    filled2 = False
    If tileMap[c-1][r-1] = -1 Then
    
  5. If yes, then check if the current row is not the top one.
    If r > 1 Then
    
  6. If yes, start another FOR loop going backwards to create a temporary row ranging from the current row minus one to one (the top row).
    For Local r2:Int = r-1 To ...

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