Back to Entry Page

Demonstration: 'Shootout' Game

Screenshot from demonstration project

Here's yet another turn of the crank on our venerable timelineVsScripting (bouncing ball) demo. The code was built by modifying one of last week's breakout demos. This time the projectile travels along a diagonal instead of just a vertical line. You determine trajectory by rotating a visible aiming point 45 degrees left or right, using the right and left arrow keys. Clicking the mouse releases the projectile.

There are (at least) two ways to make this work. The clever method involves calculating the angle of the aiming point, then using trigonometric functions to derive the slope of projectile's flight path. This demo uses a much less refined method. Okay, a stupid method.

We control the trajectory of the projectile by rotating a movie clip that contains it. This eliminates all that bother about trig functions. However, if the aiming point rotates and the projectile rotates with it, then changing the aim while the ball is in flight will cause the ball to swerve. This is nice if you're simulating a wire-guided tank-killer, but not very appropriate for cannon balls and bee-bees.

So we locate the moving projectile on a second copy of the visible aiming point. This twin system holds its place until the mouse button (or trigger) is pressed, at which point it takes on whatever rotation has been assigned to the visible aiming point. If everything in the second system except the projectile is given an alpha of zero, the whole thing looks quite smooth.

Stupid is as stupid scripts.

The Flash source file, shootoutDemo.fla, is in MMShare/shootoutDemo on Crow.


University of Baltimore Logo

Copyright © 2002 School of Information Arts and Technologies