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 — checking neighboring horizontal tiles

We will create two methods for checking the neighboring tiles, as we need to do this for each axis (x and y), separately.

  1. Inside the game class, add a new method called CheckGemsX. As parameters, it will take the column and row, the gem type, and a mark flag.
    Method CheckGemsX:Int(column:Int, row:Int, gem:Int, mark:Bool = False)
    
  2. First, add a local found variable of the type INT. It will be set once we find similar gems.
    Local found:Int = 0
    
  3. Initialize the slot.
    tileMap[column-1][row-1] = -1
    
  4. Check if column is greater than 1. It means there must be gems on the left.
    If column > 1 Then
    
  5. Start a FOR loop, stepping backwards from column -1 to the first gem on the left.
    For Local c:Int = (column-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