Game Development Reference
In-Depth Information
3D manipulation to construct the game environment and move the
various components of gameplay.
The SimpleTunnelShooter Example
The support files for this exercise are in the Chapter 11 folder; the
main file is SimpleTunnelShooter.fla. All the class files for it are in
the tunnelshooter package. This is to eliminate any interference
withotherexamplesfromthischapter,aswellastodemonstrate
use of packages for keeping code isolated and organized.
The Basic Mechanics
The game will generate a tunnel in the shape of an octagon through
aseriesofsurface tiles positioned in 3D space. There need to be
enough tiles to create a sense of depth, like the tunnel extends a
long distance. The player will move the character around the edges;
each side of the tunnel is a
Enemies will be generated at the
far end of the tunnel and moved toward the player over time.
step.
Classes
There are five classes that we will utilize for this example:
￿
Game.as: This controls the input and interaction with the other
components
the main
engine.
￿
Tunnel.as: It is a DisplayObject that manages construction of the
3D tunnel and facilitates interaction with the tiles that make up
the sides of the tunnel.
￿
TunnelTile.as: This is a DisplayObject that will be distorted in
3D space and used in conjunction with other tiles to simulate
the 3D surface of the tunnel.
￿
Enemy.as: This is the class defining enemy objects that will be
created at one end of the tunnel and moved toward the
opening of the tunnel.
￿
Player.as: This is actually just a stub class; it has no code for this
example other than to establish a link between a symbol in the
library
it would be used later to bestow interactive abilities to
the player object.
We
starting with
the Tunnel, TunnelTile, and Enemy classes, and then pulling all of
them together in the Game class.
'
ll work with these classes from the
inside out,
The Tunnel Class
In order to create the illusion of depth, we
llcreatea3Dsurface
from multiple flat objects, or tiles. Because it doesn
'
'
t need access
to multiple frames, Tunnel extends the Sprite class.
Search Nedrilad ::




Custom Search