Note About This Book: Advanced Lingo For Games was written by Gary Rosenzweig in 2000 for users of Macromedia Director 7. It is presented here for free on an as-is basis, with no updating. Most of the information and code here can be used in the most recent version of Director. The book has been reproduced from the final editing files archived in 2000, and not the final proof galleys. So some minor differences between this version and the printed version my exist. The entire contents of this book are Copyright 2000, Gary Rosenzweig. No part may be reproduced or copied without written permission. The text here is provided for individual use only.
Want to thank me for making this book available for free? Just buy Special Edition Using Macromedia Director MX and we'll call it even!

Advanced Lingo For Games
by Gary Rosenzweig


Chapter 12 Section 1

Game Overview

This game consists of a paddle at the bottom of the screen that the user can move back and forth. The purpose of the paddle is to hit a ball that moves in two dimensions.

In addition, a group of bricks appear at the top of the screen that must be destroyed by the ball. The player uses the paddle to direct the bouncing ball and hit the bricks until all are destroyed. If the player misses the ball, it falls off the bottom of the screen and the player loses a life. Figure 12.1 shows the game in progress.

Figure 12.1
This Paddle Bricks game is in progress.

Moving the Paddle

The paddle's vertical position remains stationary, while the horizontal position matches that of the cursor. This is done by simply changing the locH property of the paddle's sprite.

The Ball

The ball must bounce off the sides and top of the screen. It should also bounce off the bricks.

It would be easy to have the ball also bounce off the paddle. However, a true bounce would mean that the ball bounces off in exactly the opposite angle from which it hit. If we used this standard law of physics, then the paddle would be little more than a device used to prevent the ball from falling off the screen.

Instead, we will change the angle of reflection according to where the ball hits the paddle. If the ball hits on the right side of the paddle, then the ball will fly up and to the right. If the ball hits the left side of the paddle, then the ball will fly off and to the left. The slope of the angle depends on how far from the center of the paddle the ball hits. So, if the ball hits in the center of the paddle, it will fly straight up. This allows the player to direct the movement of the ball.

Bricks

The only purpose of the bricks is to wait until the ball hits them. When it does, the brick disappears, the ball is reflected, and points are scored. When all bricks are gone, the level is over and the game should advance to a more difficult level.

The look of the bricks can vary from brick to brick. You can use different members. In the example movie on the CD-ROM, a single 1-bit member is used, but the brick sprites have different colors applied to them to make the game more interesting.

Levels

As with "Space Rocks" and "Sprite Invaders," one level is represented by one frame. The ball behavior has a setting for speed that can be increased for every level.

In addition, the bricks can take on a different layout for each level. You can place more bricks and make them worth different amounts of points. You can even place strange-looking bricks surrounded by normal bricks. The strange-looking ones can be worth a lot of points and play different sounds when hit.

Special Effects

In addition to being worth different amounts of points and using different members or colors, the bricks can also play different sounds when hit. You will probably not want to have a different sound for every brick, but rather assign points and sounds to groups of bricks.

This method allows you to have a musical-sounding game. Each row of bricks, for instance, can play a different note when hit. Unusual bricks can play tunes or explosion sounds.