13.3. The cCritterBullet

As mentioned in the last section, when a cCritterArmed fires a shot, its shoot method is called, and a new bullet gets initialized in two stages. First the bullet’s no-argument constructor cBullet() is called. The constructor does the following.

  • Sets the bullet’s _collidepriority to the relatively high value cCollider::CP_BULLET. Since this value is higher than cCollider::CP_CRITTER, this means that when a bullet hits a normal critter, the bullet invokes the collide method as the caller instead of as the argument.

  • Tells the bullet to have a limited lifetime by setting _usefixedlifetime to TRUE and setting the size of _fixedlifetime to cCritterBullet::FIXEDLIFETIME, which happens to be set to 3.0 seconds. (Note that you ...

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.