15.1 The Defender3D specification and design


As in the section on the Spacewar game in Chapter 14: 2D Shooting Games, we describe: (S1) the concept, (S2) the appearance, (S3) the controls, and (S4) the game play.

(S1) Concept

Although the inspiration for the game was the old 2D Defender game, the current implementation is more like a 3D Space Invaders. Polygons rush at you, and you have to shoot them before they pass you and hit the back wall of your world.

(S2) Appearance

In the screen capture of Defender3D, the circle at the center is the player; the viewer rides directly behind the player and looks 'through' it. The marks near the middle of the player are bullets the player recently shot. The thick polygons are the onrushing flying critters the player is trying to shoot, while the disks on the bottom of the space are bouncing fragments resulting from the critters that have already been shot. The lines indicate the limits of the world. A sky bitmap covers the far wall.

The Defender3D game. Round objects are the 'prop frags'


(S3) Controls

The Arrow keys move the player Left/Right and Up/Down. The player can also move forward and backwards a bit with PgUp/PgDn. Spacebar fires bullets straight forward. It's also possible to play in more of a Doom mode by leaving the player in the middle of the screen and left-clicking or left-dragging the mouse to shoot in different directions. The Arrow keys mode seems to be more fun.

(S4) Behavior

You try to shoot all the polygons, each one that you hit adds ten points to your score; each one that gets past you costs you one health point. When you shoot a polygon it releases a shower of coins, that is, disks that bounce towards you along the bottom of the world. You can gain health points by bumping the player into a coin ? a bump kills the coin and adds a point to player's health. The coins evaporate after three seconds, so you have to shoot a critter that's not too far off if you hope to eat its coins.


UML diagram

The class design is fairly simple. Our cGameDefender3D class has a player, player bullets, props, and prop frags. Although we don't show it in Figure 15.1, the cGameDefender3DProp and cGameDefender3DPropFrag inherit from cCritter.

Figure 15.1. UML diagram of the Defender3D Classes


We won't bother printing any header file information here, as the headers are similar to what we already saw for the Spacewar game.

    Part I: Software Engineering and Computer Games
    Part II: Software Engineering and Computer Games Reference