18.2. Games with walls

In many games, like PacMan, the critters are limited to move within the corridors of a maze. How can we implement this?

The simplest approach is to just put in a number of cCritterWall objects and let the critters bounce off the walls. Use as few walls as possible so as to keep down the number of pairs that you’ll be processing in your collision-checking – that is, use one long wall in preference to two short walls butted together end to end.

The speed of the Pop Framework is indeed sufficient to handle worlds with little wall mazes such as PacMan.

The Dambuilder sample game isn’t really a game, it’s more of a starting point. We’ll have a couple of exercises on it below (Exercises 18.1 and 18.2).

For a more Doom-like adventure ...

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.