13.1 High-level design for cCritterArmed and cCritterBullet


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

graphics/13fig01.gif

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

graphics/13fig02.gif

Table 13.1. The special classes used for shooting.

Class

New methods

Overrides

cCritterBullet

initialize

isTarget

update

collide

collidesWith

cCritterArmed

aimAt

shoot

draw

update



Software Engineering and Computer Games
Software Engineering and Computer Games
ISBN: B00406LVDU
EAN: N/A
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net