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

Preface

Welcome to Monkey Game Development Beginner's Guide. This book will teach you (as a step-by-step guide) how to develop 2D games with Monkey. With eight sample games included, the book covers a great range of the toolset and important game development techniques. You will also learn how to deploy your games to mobile platforms, such as iOS, Android, and other platforms, such as OSX and Windows.

When you are done studying this book, the knowledge you have gained about creating 2D games with Monkey will have you transformed from being a beginner-level game developer to experienced creator of your virtual dreams. So what are you waiting for? Start reading and create some Monkey-powered games!

What this book covers

Chapter 1, Monkey Huh?, takes you on a fast-paced tour of what Monkey is, which tools are included, what games you can create with it, and which programming features Monkey provides for you, in general.

Chapter 2, Getting to Know your Monkey—a Trip to the Zoo, will show you the first steps in working with the Monk editor and creating your very first Monkey script. The next step is to develop a PONG clone with Monkey and to learn the basic structure of a Monkey script. Running your game inside the browser is the final goal for this chapter.

Chapter 3, Game #2, Rocket Commander, teaches you how to develop a Missile Command clone. During its development, you will learn more about how to render drawing primitives, read mouse input, handle different game objects with their own game logics in separate files, and use basic circle-to-circle collision detection. Exporting your game to HTML5 will round up this chapter.

Chapter 4, Game #3, Comet Crusher, is the first chapter where we will make extensive use of an external game framework called fantomEngine. It will allow us to develop our game even faster, because we don't need to develop our own basic methods for rendering and updating objects anymore. During the development of an Asteroids clone, you will learn how to use the framework, display images, load and save a high-score list, and use timers and automatic object updating events. At the end of the chapter, you will export your game to the FLASH platform.

Chapter 5, Game #4, Chain Reaction, covers the development of a typical casual puzzle game called Chain Reaction. You will utilize features of the fantomEngine even further, learn how to use touch input, scale content depending on the devices screen size, and optimize your collision detection. Playing sounds, transition objects, using typical mobile device events, and exporting your game to the Android platform are covered in this chapter, too.

Chapter 6, Game #5, Balls Out!, will cover game development for the iOS mobile platform and a typical hardware feature of mobile devices called the accelerometer. During the development of a Breakout-inspired game called Balls Out!, you will learn how to use tilt movement to control your game, how to create and use particle emitters, and store data in a different container objects called stacks.

Chapter 7, Game #6, At The Docks, which covers the development of a Sokoban clone, will show you how to read joystick input for your XNA game and covers another collision detection method. It shows you how to load game levels that are stored in text files.

Chapter 8, Game #7, Air Dogs 1942, brings you to the development of Air Dogs 1942, a typical WWII-based arcade shooter. We will focus on creating a nice single player computer AI to control the enemy planes. The final goal will be to deploy your game to the OSX and Windows desktop platforms.

Chapter 9, Game #8, Treasure Chest, is a mix of everything we have learned so far, put together, to create a Bejewled clone called Treasure chest.

Chapter 10, Making Some Money for Bananas, will show you how to sign, prepare your apps, and load them up to different markets, such as the the Apple App store or the Android market. Making money from your games is the goal of this chapter. For this, it will cover how to use external features such as implementing advertising in your mobile game, too. You will also learn what kinds of markets exist for your apps.

Who this book is for

Do you want to quickly create games deployable to all the major desktop and mobile platforms? If so, look no further. You will learn how to utilize the highly versatile Monkey programming language/toolset to create 2D games, deployable almost anywhere. Only very basic knowledge of Monkey is required, so if you are a total beginner, it will help if you have studied the samples that come with Monkey.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action — heading

  1. 1. Action 1

  2. 2. Action 2

  3. 3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find some other learning aids in the book, including:

Have a go hero — heading

These set practical challenges and give you ideas for experimenting with what you have learned.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The source code file, fantomEngine.monkey is included with this book."

A block of code is set as follows:

g.SaveHighScore()
Return 0
Endif

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

Field layerBackground:ftLayer
Field layerGame:ftLayer
Field layerClouds:ftLayer
Field layerInfo:ftLayer
Field layerTitle:ftLayer

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.