Book Image

Flash Game Development by Example

By : Emanuele Feronato
Book Image

Flash Game Development by Example

By: Emanuele Feronato

Overview of this book

<p>You can't call yourself a Flash game developer unless you know how to build certain essential games, and can quickly use the skills and techniques that make them up.<br /><br />Flash Game Development by Example is an ultra-fast paced game development course. Learn step-by-step how to build 10 classic games. Each game introduces new game development skills, techniques, and concepts. By the end of the book you will have built ten complete games &ndash; and have the skills you need to design and build your own game ideas.<br /><br />The book starts with simple well known puzzle games: Concentration and Minesweeper. After learning the basics of game design you&rsquo;ll introduce AI with a four-in-a-row game. Then as you build your own versions of old arcade games such as Snake, Tetris, and Astro Panic. The book ends with a collection of modern casual classics.</p>
Table of Contents (17 chapters)
Flash Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Where to Go Now
Index

Placing the gems


Placing the gems on stage may seem just a matter of adding some random DisplayObjects to Display List, but you'll see that we'll find ourselves in trouble very soon.

The idea: We are going to populate the array and physically place the jewels in the same script, so we'll fill the array with random integer numbers between 0 and 6, to represent each of the possible jewels. At the same time, we'll place a gem in the proper position and show the proper frame.

The development: You already know what we need to place the jewels as it's the same concept as placing cards, mines, crates, or whatever kind of asset in a tile-based game. Anyway, let's recap once again. We need:

  • a two-dimensional array to represent the game field

  • a DisplayObject to act as a container for all jewels

  • an instance of gem_mc object

A couple of for loops will populate the array with random numbers, as gem_mc objects will be placed on the stage.

Without closing bejeweled.fla, create a new file and from New Document...