1. To create a comet, we need a new method called
CreateComet
. The parameters are the kind of comet, its position, the travel speed, and angle.Method CreateComet:ftObject(k:Int, xp:Float, yp:Float, speed:Float, speedAngle:Float)
2. Define a local
ftObject
calledcom
.Local com:ftObject
3. Depending on the size of the comet, create the comet object from different locations of the sprite atlas. Also, set the radius depending on the size.
If k = cmSmall Then com = eng.CreateImage(atlas, 0,32,16,16, xp, yp) com.SetRadius(4) Endif If k = cmMiddle Then com = eng.CreateImage(atlas, 32,0,32,32, xp, yp) com.SetRadius(12) Endif If k = cmLarge Then com = eng.CreateImage(atlas, 64,0,64,64, xp, yp) com.SetRadius(24) Endif
4. Now, set the speed and the angle that the comet will move at.
com.SetSpeed(speed, speedAngle)
5. Next, we set a random starting angle and spinning speed.
com.SetAngle(Rnd(0,359)) com.SetSpin(Rnd(-4,4))
6. Store the comet size constant into the
tag
field...
Monkey Game Development: Beginner's Guide
By :
Monkey Game Development: Beginner's Guide
By:
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
Free Chapter
Monkey—Huh?
Getting to Know your Monkey—a Trip to the Zoo
Game #2, Rocket Commander
Game #3, CometCrusher
Game #4, Chain Reaction
Game #5, Balls Out!
Game #6, At The Docks
Game #7, Air Dogs 1942
Game #8, Treasure Chest
Make Some Money for Bananas
Customer Reviews