Graphics Programs Reference
In-Depth Information
When neither the Left Arrow nor Right Arrow keys are pressed, the steering wheel
gradually returns to a normal position (lines 158-167, see file on CD).
If the Up Arrow key is pressed, the camera is accelerated in the z-direction, an acceler-
ating sound is played, and the needle on the speedometer is rotated clockwise. Pressing
the Down Arrow key produces a similar but opposite behavior.
168
169
170
171
172
if (Key.isDown(Key.UP))
{ camdz -= camspeed; // accelerate camera
accelerateFX.start();
dash_mc.needle_mc._rotation = - camdz;
if ( dash_mc.needle_mc._rotation < 0 && dash_mc
.needle_mc._rotation > -60 )
{ dash_mc.needle_mc._rotation = -60; }
} else if (Key.isDown(Key.DOWN))
{ camdz += camspeed; // decelerate camera
dash_mc.needle_mc._rotation = - camdz;
}
173
174
175
176
177
178
The remaining part of the onEnterFrame handler displays the objects, keeps the player
from moving too far left or right, and checks for the end of the game. When the game
is over, the handler is deleted, and general cleanup is performed like the last game
before moving to the score frame.
The parallax function uses two parameters: a layer , which represents the movie clip
to be moved, and a speed , which controls how fast the movie clip will move. The speed
can be either positive or negative, depending on the desired direction. The sky and hills
are designed for continuous movement and are used with different speeds to provide
parallax motion.
Some possibilities to enhance this game include the following. Add more obstacles to
the game. Each obstacle could impact your score differently. You could also add a fuel
limit and ways to refuel the car. This could be accomplished through a keypress or other
items randomly placed in the 3D space.
Search WWH ::




Custom Search