Designing and Scoring a Pac-Man Style Maze Game with Flash
by Aria Danika
with character design by Chris Norman
Aria Danika is an interactive developer/artist, senior moderator at Flashkit.com, and member of the Hypermedia Research Centre in London.
I grew up playing games. However, most of my early experiences with video games were limited to arcades, friends' houses, and trying to convince my parents that an Atari 2600 was something no family should be without.
One of my favorite early games and sources of inspiration was a simple, random-generated maze titled Diamaze (1990), designed by Steve Herring. Diamaze was a puzzle/maze game where you have about a minute to collect as many diamonds as you can, using your keyboard arrow keys, before the lights go out.
Tile-based games have been around for a very long time and can serve as a clever way to build a game environment without consuming too much memory. The main aspect of this technique involves slicing up your game background into reusable square blocks. Then you place them together (tile) using code in order to build a map that acts as the data structure for the game. This technique is similar to the concept of using reusable symbols in your Flash movie to save time and space.
It Works Like This
This game is constructed using tiles (also known as cells), which are square graphics stored as movie clips. These are "tiled" using ActionScript to generate the game environment: a top-down maze. Complete with sound effects and a scoring feature, users are able to use the arrow keys to move the character and collect balloons. Here are the basic steps of the project:
Attach the script that allows the user to begin the game.
Attach two reusable tree maze tiles dynamically with ActionScript to construct the game field.
Insert the main character dynamically, by assigning Linkage properties to the movie clip.
Write a custom collision-detection script that calculates the position of the main character against the bounds of the tree tiles and the balloons.
Set up the character movement by creating motion Listeners that check for key presses.
Keep game score by counting the number of collisions with collectable items and displaying the output in a text field.
Attach sound effects to provide feedback to your user when he is interacting with your game.
Figure 5.2 To begin, you'll set up the character introduction and maze.
Figure 5.3 Then the fun begins. See how many balloons you can collect.