7.4. Implementing forces

The base class cForce::force returns a zero vector, but we have ‘global’ force classes cForceGravity, cForceDrag, and cForceVortex which return non-trivial values. We use them in the Ballworld and Dambuilder games, discussed in Chapter 18: Interesting Worlds. We also have ‘relative’ steering force classes liked cForceObjectSeek, cForceClassEvade, and cForceEvadeBullet.

Figure 7.2 is a class diagram of all the forces we provide with the Pop Framework.

Figure 7.2. Class diagram of the cForce child classes

The idea is that each force(cCritter*) method should return a force that the critter will divide by its mass and add ...

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.