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

Making your move


Everything is ready to let the player drop his/her disc. You can check whether each column represents a legal move or not, and you know which row will occupy a falling disc, given a column.

The idea: When the player clicks the mouse, we check if the column he picked is a legal one, in this case we place the disc in the proper row and let the other player move. At the moment, there isn't a computer-controlled opponent yet, so you will have to play both with red and yellow discs.

The development: To make the player drop the disc with a mouse click, you have to import MouseEvent class in disc_movieclip.as to use your old friend MouseEvent.CLICK listener.

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;

You also need to know which player is playing through all classes, so add a new variable to class level variables.

private var currentColumn:int;
private var currentPlayer:uint;
private var par:Main;

currentPlayer will store the number...