Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

9. Game #8, Treasure Chest > Time for action — refilling the tile map

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 1 Step -1
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial