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 — spawning an enemy


This new method called SpawnEnemy will create one enemy and initialize its position and the path to follow:

  1. 1. Create a new method called SpawnEnemy, inside the game class. It will have the x position as a parameter. The y position will be fixed and always on top.

    Method SpawnEnemy:Int (x:Float)
    
  2. 2. Add a new instance of the Enemy class to the enemyList field of the game class. The y position is always 0 and there are 25 path nodes to be created:

    enemyList.AddLast(New Enemy(x,0.0,25))
    Return 0
    End
    

What just happened?

This method created an enemy with 25 path nodes and stored it inside the enemy list of the game class.

Starting a new game

Things that should be done multiple times inside a game should be placed inside a function or a method. Starting a new game will be one of these things.