PacktLib: Monkey Game Development: Beginner's Guide

Monkey Game Development

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Monkey—Huh?

Game development for the rest of us

Cross-platform development

Compiler or translator?

The Monkey toolbox

Time for action — installing Monkey

Let's have a little playtime

Time for action — playing Pirate TriPeaks

Time for action — playing Surviball

So let's go for something big? No!

Time for action — read the manual

Summary

Getting to Know your Monkey—a Trip to the Zoo

Call the Monk and start praying—the Monkey IDE

Time for action — opening a sample script

Where is my navi?

Time for action — navigating to the Main() function

Save... save... save!

Time for action — saving a script

Projects—bringing in some organization

Time for action — creating a project

The Monkey programming language

Time for action — Monkey's Hello World

Running your first script in a browser

Our first little game... PONGO

Time for action — the basic structure of your game

Pongo's data structure

Time for action — adding some data fields

Time for action — rendering the game field

Time for action — drawing the ball and the paddles

Time for action — player paddle movement

Time for action — moving the enemy paddles

Time for action — moving the ball

Time for action — controlling the ball with the player's paddle

Time for action — letting the enemy paddles fight back

Time for action — acting on the different game modes

Exporting your game as an HTML5 website

One more thing... comment your code!

Summary

Game #2, Rocket Commander

The game objects

The basic file structure

Time for action — building the basic file structure of the game

Hold that data—RocketCommander's data structure

Time for action — creating the general data structure of the game

Detailing the Update process

Time for action — detailing the Update process

Detailing the Render process

Time for action — detailing the Render event

Enhancing the OnCreate event

Time for action — detailing the OnCreate process

Let's build some cities

Time for action — building some cities

Time for action — changing the gameClasses file

Time for action — spawning some cities in the game

Time for action — rendering the cities

Get the launchers ready!

Time for action — implementing the rocket launchers

Time for action — changing the gameClasses file again

Time for action — creating some launchers in the game

Time for action — updating the launchers

Time for action — modifying the menu update process

Time for action — rendering the launchers

Fire! Blast them to pieces!

Time for action — implementing some rockets

Time for action — modifying the gameClasses file

Time for action — modifying the launcher class

Time for action — updating the rockets

Time for action — rendering the rockets

And it goes BOOM!... Explosions

Time for action — implementing explosions

Time for action — modifying the gameClasses file

Time for action — modifying the rocket class

Time for action — updating the explosions

Time for action — rendering the explosions

Don't fear the enemy—bombs

Time for action — creating the bomb class

Time for action — modifying the gameClasses file

Time for action — updating the bombs

Time for action — rendering the bombs

Time for action — modifying the UpdateGame method

Displaying the game score

Time for action — displaying the game score

Summary

Game #3, CometCrusher

Using a game framework—the fantomEngine

Game resources

The game objects

The basic file structure

Time for action — create the main source file and its folders

Open the storage please—the data structure of CometCrusher

Time for action — creating the data structure

First changes to the OnCreate method

Time for action — modifying the OnCreate method

Detailing the Render process

Time for action — detailing the OnRender method

This is a setup—creating the game objects

Time for action — creating some layers

Time for action — implementing some stars

Time for action — setting up the player ship

Time for action — creating a method to load sounds

Time for action — creating some game info text objects

Time for action — adding a title screen

Time for action — setting up the high score list

Time for action — create a comet

Time for action — creating some comets

Time for action — finalizing the OnCreate method

We need help—more methods for the Update process

Time for action — loading a high score list

Time for action — showing the high score list

Time for action — the ActivateShield method

Time for action — determine the time delta

Time for action — updating the info text

Time for action — creating a StartNewGame method

Time for action — spawning some engine particle FX

Time for action — creating some explosions

Time for action — spawning some shots

Time for action — saving the high score list

Finalizing the OnUpdate method

Time for action — finalizing the OnUpdate method

Bring in the action—shaping the engine class

Time for action — detailing the collision detection

Time for action — detailing the OnObjectTimer method

Time for action — detailing the OnObjectUpdate method

Time for action — detailing the OnLayerUpdate method

One last thing—creating a FLASH game

Summary

Game #4, Chain Reaction

Modifying the HTML5 canvas size

Time for action — modifying canvas size

Some development basics

Game resources

Game objects

The basic app structure

Time for action — creating the main source file and its folders

The data storage

Time for action — creating the data structure

First changes to the OnCreate event

Time for action — first changes to the OnCreate method

Detailing the OnRender event

Time for action — detailing the OnRender method

Setting up the game objects

Time for action — loading the game sound effects

Time for action — creating layers for the game

Game screen

Time for action — creating buttons

Time for action — creating info text objects

Time for action — composing the game screen

Time for action — creating the title screen

Finalizing the OnCreate event

Time for action — finalizing the OnCreate method

Helper functions for the update process

Time for action — creating collision circles

Time for action — creating the atom elements

Time for action — creating a StartNewGame method

Time for action — implementing the GetDeltaTime method

Time for action — creating a method to update the text information

Detailing the OnUpdate event

Time for action — finalizing the OnUpdate method

Introducing the OnSuspend event

Time for action — modifying the OnSuspend event

Introducing the OnResume event

Time for action — updating the OnResume method

The heart of the game - the engine class

Time for action — enhancing the OnObjectTouch method

Time for action — detailing the OnObjectTransition method

Time for action — acting on timer events

Time for action — detailing the collision detection

Creating an Android app

Summary

Game #5, Balls Out!

Which frameworks and modules are used?

Game resources

Our lovely game objects

The basic app structure

Time for action — creating the basic file structure

Modifying the HTML5 canvas size for testing

Time for action — modifying the HTML5 output

The data storage

Time for action — creating the data structure

First changes to the OnCreate event

Time for action — first changes to the OnCreate method

Detailing the OnRender event

Time for action — detailing the OnRender method

Setting up the game objects

Time for action — loading the game sound effects

Time for action — creating layers for the game

Time for action — creating text buttons

Time for action — composing the game screen

Time for action — creating the title screen

Finalizing the OnCreate event

Time for action — finalizing the OnCreate method

Helper methods for the update process

Time for action — creating the tiles

Time for action — creating the ball

The bad guys—our beloved enemies

Time for action — creating the enemy class

More helper functions

Time for action — spawning an enemy

Time for action — creating a StartNewGame method

Bring me up-to-date—detailing the OnUpdate event

Time for action — detailing the OnUpdate method

Eye candy—particle effects

Time for action — creating the particle emitter class

Time for action — spawning a particle emitter

The heart of the game—the engine class

Time for action — enhancing the OnObjectTouch method

Time for action — acting on object update events

Time for action — acting on layer update events

Time for action — detailing the OnObjectTransition method

Time for action — detailing the collision detection

Creating an iOS app

Summary

Game #6, At The Docks

Frameworks and modules used

Game resources

The game objects

The basic app structure

Time for action — creating the basic file structure

Modifying the HTML5 canvas size for testing

Time for action — modifying the HTML5 output

The storage for our data

Time for action — creating the data structure

Setting up the game objects

Time for action — creating layers for the game

Time for action — creating the title screen

Detailing the OnCreate event

Time for action — finalizing the OnCreate method

Some flexible methods for the update process

Time for action — creating the player

Time for action — loading the level tiles

Time for action — creating a StartNewGame method

Bring me up-to-date—detailing the OnUpdate event

Time for action — detailing the OnUpdate method

And action!—the engine class

Time for action — updating each object

Time for action — detailing collision detection

Time for action — detailing the OnLayerTransition method

Creating a XNA app

Summary

Game #7, Air Dogs 1942

Frameworks and modules used

No silver, no gold, but… our game resources!

The game objects

The basic app structure

Time for action — setting up the basic file structure

Storing data

Time for action — creating the data structure

First changes to the OnCreate event

Time for action — first changes to the OnCreate method

Setting up the game objects

Time for action — loading the game sound effects

Time for action — creating layers for the game

Time for action — composing the background screen

Time for action — creating the clouds

Time for action — creating info text objects

Time for action — creating the title screen

Finalizing the OnCreate event

Time for action — finalizing the OnCreate method

Methods for the update process

Time for action — spawning the player plane

Time for action — spawning an enemy plane

Time for action — creating a StartNewGame method

Detailing the OnUpdate event

Time for action — detailing the OnUpdate method

Making it look nicer—some particle effects

Time for action — emitting the smoke

Time for action — creating the explosion

Time for action — spawning a shot

The brain—Computer AI (Artificial Intelligence)

Time for action — following the player

The heart of the game—the engine class

Time for action — enhancing the OnObjectTimer method

Time for action — detailing the OnObjectTransition method

Time for action — acting on object update events

Time for action — detailing the collision response

Time for action — acting of layer update events

Creating a GLFW app

Summary

Game #8, Treasure Chest

Frameworks and modules used

Reusing code

The parts of the game... resources

And here they are… the game objects!

Preparation… the basic app and project structure

Time for action — creating the basic file structure

Creating 2D arrays

Time for action — creating 2D arrays

Storing information… the data storage

Time for action — creating the data structure

First changes to the OnCreate event

Time for action — first changes to the OnCreate method

About the OnRender event

Setting up the game objects

Time for action — loading the game sound effects

Time for action — creating layers for the game

Time for action — composing the background screen

Time for action — creating the title screen

Time for action — creating the "game over" screen

The menu please… creating the menu screen

Time for action — creating text buttons

Time for action — creating the menu screen

Time for action — creating the score screen

Time for action — creating the activate layer method

Finalizing the OnCreate event

Time for action — finalizing the OnCreate method

Dealing with the high-score list

Time for action — loading and saving the high-score list

Time for action — showing the high-score list

Managing the tile map

Time for action — getting tile slot IDs

Time for action — setting a tile slot ID

Check/mark the neighboring tiles

Time for action — checking neighboring horizontal tiles

Time for action — check neighboring vertical tiles

Time for action — clearing the tile map

Time for action — counting matching tiles

Time for action — creating a gem

Time for action — refilling the tile map

Methods for the update process

Time for action — creating a StartNewGame method

Time for action — updating the text info

Time for action — showing the "game over" screen

Time for action — showing the menu

Bring me up-to-date—detailing the OnUpdate event

Time for action — detailing the OnUpdate method

Vroom… vroom—the engine class

Eye candy—particle effects

Time for action — spawning an explosion

Time for action — acting on object timer events

Time for action — enhancing the OnObjectTouch method

Time for action — detailing the OnObjectTransition method

Time for action — acting on layer update events

Summary

Make Some Money for Bananas

Which markets exist for your game?

Existing methods of making money

Implementing advertising in your app

Implementing MobFox in iOS

Time for action — creating a new MobFox app ID

Time for action — adding the MobFox framework to the XCODE project

Time for action — modifying the code to display ads

Implementing MobFox in Android

Time for action — creating a new MobFox app ID

Time for action — modifying the project to display ads in Android

Time for action — creating an app ID in InMobi

Time for action — add a backfill in MobFox

Publishing in the Android market

Publishing in Apple's App Store

Time for action — adding an icon to the Xcode project

Time for action — setting the product name in the target settings

Time for action — setting the distribution code signing profile

Time for action — creating the app package

Summary