02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10: Keep it modular<br />

a game is unlikely <strong>to</strong> become a world-beater. The input from the user <strong>to</strong> control the horizontal<br />

position and orientation of the descending tile block has been overlooked in the summary. When<br />

you are writing your plan you need <strong>to</strong> work extremely hard <strong>to</strong> ensure that you have considered<br />

all the options. But the single most important consideration when writing the spec for a game is<br />

<strong>to</strong> decide what the user actually does when playing your game. If all they do is admire your lovely<br />

graphics then go back <strong>to</strong> the drawing board.<br />

From a plan <strong>to</strong> a structure<br />

Now we have a plan, but how do you intend <strong>to</strong> turn this in<strong>to</strong> a working game? A very<br />

popular concept in computer science is <strong>to</strong> use the <strong>to</strong>p-down approach. Start by presenting<br />

an overview of the game, and then break the game down in<strong>to</strong> manageable chunks that can<br />

be developed in isolation. This methodology is a very effective technique when computer<br />

programming – creating chunks of an application that can be developed in isolation, and debugged<br />

separately.<br />

Returning <strong>to</strong> our Tetris example, let’s try <strong>to</strong> break down the overview in<strong>to</strong> small chunks of<br />

functionality.<br />

Table 10.1 Overview of the methods required for game<br />

Initialization When the movie clips that form the game board are created<br />

by duplication.<br />

New Game When all the game variables are initialized and the game<br />

board is cleared.<br />

User Input We are going <strong>to</strong> need a keyboard reader that moves the<br />

Next Piece<br />

Genera<strong>to</strong>r<br />

playing piece if such a movement is possible.<br />

We will need <strong>to</strong> be able <strong>to</strong> create the next piece that is<br />

going <strong>to</strong> be used in the game that randomly determines the<br />

next piece <strong>to</strong> fall. The game is over when a new tile cannot<br />

be added, so if this function returns false then this indicates<br />

the end of the game.<br />

We will need <strong>to</strong> be able <strong>to</strong> confirm whether the descending<br />

tile can move <strong>to</strong> a certain game board position.<br />

We will need <strong>to</strong> be able <strong>to</strong> confirm when a completed row<br />

has occurred.<br />

This is where the game board will be adjusted <strong>to</strong> remove a<br />

Legal Move<br />

Confirmation<br />

Complete Row<br />

Checker<br />

Complete Row<br />

Removal completed row.<br />

Update Game The game board is controlled using a multi-dimensional<br />

Board<br />

array.<br />

Game Over This could be a complex animation or a simple text box.<br />

Timer update If the score is going <strong>to</strong> use elapsed time as well as removed<br />

rows then we will need <strong>to</strong> show a timer.<br />

Score update The score should be continuously updated based on the<br />

rows removed and the elapsed time.<br />

137

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!