Game Development Reference
In-Depth Information
Finite State Machine Class
UpdateMachine()
m_States
Process
Commands
Class
Attack
Enemy
Class
Retreat
Class
Patrol
Class
Figure 8-3. Implementing the finite state machine
Creating the Tank Enemy
The tank enemy consists of the tank's graphics as well as the tank's artificial intelligence.
Creating the Tank Graphic
The graphics for the tank are two pyramid-shaped polygons. The lower polygon representing the
tank body is identical to the top polygon representing the tank's turret, except for being slightly
larger.
The Pyramid2 class holds the data for the tank body and tank turret in the Pyramid2Vertices array
Listing 8-8.)
Listing 8-8. The Tank Graphics
public class Pyramid2 extends Object3d
{
static float[] Pyramid2Vertices =
{
// Triangle Shape
// Left Side u v nx, ny, nz
 
Search WWH ::




Custom Search