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

The game field


As usual, the first thing we have to do is defining and setting up the game field.

The idea: Just like Minesweeper game, the best solution is a two-dimensional array representing the six rows and seven columns. The first index determines the row, and the second index determines the column.

Then, any element can have these values:

  • 0: an empty cell.

  • 1: a cell occupied by player one.

  • 2: a cell occupied by player two.

Look at this picture with a typical Connect Four situation:

On the left, array indexes for each cell. On the right, array values to represent board's situation.

When the game starts, all cells are empty, so the entire array must be filled with zeros.

The development: Create a new file (File | New) then from New Document window select Actionscript 3.0. Set its properties as width to 640 px, height to 480 px, background color to #FFFFFF (white), and frame rate to 30. Also define the Document Class as Main and save the file as connect4.fla.