Game Development Reference
In-Depth Information
Chapter 8
Drone Grid Case Study: Creating
the Enemies
This chapter will cover the creation of the enemies for the Drone Grid case study. Covered first are arena
objects, which have a relatively simple behavior. Next, I cover the tank enemy, which has much more
complex behavior. In order to understand this behavior, I cover the basics of a finite state machine. Next,
I cover the finite state machine and the related classes specific to our computer controlled tank. I then
cover other classes needed to implement the tank in our game. Finally, I discuss a hands-on example
that uses the classes I have previously covered in a working example.
Creating Arena Objects
Arena objects are simple enemy objects that move through the gravity grid area. They travel in
straight lines inside the gravity grid, until they hit a grid boundary or the player's power pyramid.
After hitting a grid boundary or the power pyramid, they reverse direction with the same speed they
had before.
The ArenaObject3d class derives from the Object3d class.
public class ArenaObject3d extends Object3d
The m_ArenaObjectID variable can hold a string identifying an individual object in the game world.
private String m_ArenaObjectID = "None";
The m_XmaxBoundary and m_XminBoundary variables hold the maximum and minimum boundaries of
the game grid or game arena along the x axis.
private float m_XMaxBoundary = 1;
private float m_XMinBoundary = 0;
267
 
Search WWH ::




Custom Search