13.2. The cCritterArmed

The cCritterArmed has the ability to shoot bullets; this is what its shoot method does.

To begin with, let’s explain how the cCritterArmed::shoot gets called. The call is the responsibility of the cCritterArmed::update method, which checks if (a) the critter’s _armed flag is on, meaning that it is allowed to shoot at all, and (b) the critter’s _bshooting flag is on, meaning that it is supposed to shoot right now. When we use a cCritterArmed as a player, the _bshooting flag is something we normally turn on and off by pressing the space bar or the left mouse button. When we have a self-running ‘robotic’ cCritterArmedRobot child of the cCritterArmed class as a rival in our game, the _bshooting flag will often be continually ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.