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 — check neighboring vertical tiles

To check the gems vertically, we will use a very similar method.

  1. Just copy the previous method and make the changes according to the marked lines.
    Method CheckGemsY:Int(column:Int, row:Int, gem:Int, mark:Bool=False) Local found:Int = 0 tileMap[column-1][row-1] = -1 'Check gems on the top If row > 1 Then For Local r:Int = (row-1) To 1 Step -1 If tileMap[column-1][r-1] <> gem Then Exit If mark Then tileMap[column-1][r-1] = 99 Else found += 1 Endif Next Endif 'Check gems on the bottom If row < rows Then For Local r:Int = (row+1) To rows If tileMap[column-1][r-1] <> gem Then Exit If mark Then tileMap[column-1][r-1] = 99 Else found += 1 Endif Next Endif If mark Then tileMap[column-1][row-1] = 99 Else ...

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