Software Engineering and Computer Games

13.1 High-level design for cCritterArmed and cCritterBullet

We make a new class called cCritterArmed to encapsulate shooting behavior, and derive a cCritterArmedPlayer from it. We'll also have a cCritterArmedRobot that will have the feature of always automatically aiming at whatever cCritter * is stored in its _ptarget field. This is illustrated by Figure 13.1.

Figure 13.1. Diagram of the cCritterArmed and cCritterBullet classes

Table 13.1 lists some of the key new methods and overrides of cCritterBullet and cCritterArmed .

And Figure 13.2 is a sequence diagram showing the flow of method calls involved in having an armed critter shoot a bullet at another critter.

Figure 13.2. A sequence diagram for shooting a bullet

Table 13.1. The special classes used for shooting.

Class

New methods

Overrides

cCritterBullet

initialize

isTarget

update

collide

collidesWith

cCritterArmed

aimAt

shoot

draw

update

Категории