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.
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.
Class |
New methods |
Overrides |
---|---|---|
cCritterBullet |
initialize isTarget |
update collide collidesWith |
cCritterArmed |
aimAt shoot |
draw update |