Game Development Reference
In-Depth Information
Chapter 7
Drone Grid Case Study: Creating
the Player
This chapter covers a case study for a 3D game called Drone Grid. The objective of the game will be
to protect your pyramid, which is located in the center of the playfield, from attacking enemies. You
will do this by touching the screen and launching projectiles toward the enemies to destroy them.
You will be in a fixed location on the edge of the playfield, and you can turn left or right 90 degrees.
First, the creation of the classes representing the player's graphic in the game is presented. Next, we
create classes relating to the player's viewpoint and the player's input. This is followed by the creation
of the classes dealing with the player's weapons and ammunition. Next, we create classes dealing
with explosions and a class dealing with game object properties. Finally, we present a hands-on
example illustrating the use of our new classes, with which you will use your weapon to hit cubes.
Creating the Player Graphic
The player graphic for the Drone Grid case study will be a pyramid. In order to create this pyramid,
several classes will have to be constructed, including a new Mesh class that will draw an object's
vertices in a slightly different manner than in the MeshEx class that we have created previously.
Modifications to other classes, including the Object3d class, are also needed.
Creating the Mesh Class
The Mesh class is very similar to the MeshEx class you learned about in Chapter 4. The key
differences are in how an object's vertices are defined and how they are drawn. In the MeshEx class,
an object's vertices are listed in one array, and a list of vertices from which to draw triangles or lines
are listed in another array. In the Mesh class, there is only one array, which consists of the vertices
that make up the triangles to be drawn. Listing 7-1 shows the vertex data for a single triangle
consisting of three vertices to be used with a Mesh class. If you want to draw an additional triangle,
221
 
Search WWH ::




Custom Search