Book Image

Monkey Game Development: Beginner's Guide

By : Michael Hartlef
Book Image

Monkey Game Development: Beginner's Guide

By: Michael Hartlef

Overview of this book

Monkey is a programming language and toolset that allows its user to develop modern 2D games easily for mobile and other platforms like iOS, Android, HTML5, FLASH, OSX, Windows and XNA. With Monkey you can create best selling games in a matter of weeks, instead of months.Monkey Game Development Beginner's Guide provides easy-to-follow step by step instructions on how to create eight different 2D games and how to deploy them to various platforms and markets. Learning about the structure of Monkey and how everything works together you will quickly create eight classical games and publish them to the modern app markets. Throughout the book you will learn important game development techniques like collision detection, handling player input with mouse, keyboard or touch events and creating challenging computer AI. The author explains how to emit particle effects, play sound and music files, use sprite sheets, load or save high-score tables and handle different device resolutions. Finally you will learn how to monetize your games so you can generate revenue.
Table of Contents (16 chapters)
Monkey Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
3
Game #2, Rocket Commander
4
Game #3, CometCrusher
5
Game #4, Chain Reaction
6
Game #5, Balls Out!
8
Game #7, Air Dogs 1942
9
Game #8, Treasure Chest

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. 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. 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. 3. Initialize the slot.

    tileMap[column-1][row-1] = -1
    
  4. 4. Check if column is greater than 1. It means there must be gems on the left.

    If column > 1 Then
    
  5. 5. Start a FOR loop, stepping backwards from column -1 to the first gem on the left.

    For Local c:Int = (column-1) To 1 Step -1
    
  6. 6. If the gem found isn't the same, exit the FOR loop.

    If tileMap[c-1][row-1] <> gem Then Exit
    
  7. 7. If the mark flag was set, fill the value 99 into the tile slot. It is used if we want to mark tiles to delete them...