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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access