11.4. Colliding walls

One weak point in our standard cCritter::touch and cCritter::collide methods is that they always treat the critters as disks centered on the critter’s position. This is only slightly problematic when we have, say, a triangular critter, but it is unworkable if we have a long thin critter such as one might use for a rectangular wall.

In more advanced kinds of game programs, collision detection usually uses a sphere-based collision detection to see if a collision is possible, and then switches to a slower and more detailed algorithm that looks at bounding boxes or individual vertices of the objects being tested for collision. In the Pop Framework we presently only do this for one particular kind of shape: a rectangular ‘wall.’ ...

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.