Polling
Despite your best efforts, gameplay often turns into a mess. There are so many interacting parts that it is impossible to completely reduce coupling of gameplay code. While it makes sense that a graphics engine and a physics engine can be completely independent and decoupled, we shouldn't even try to do this with gameplay. Gameplay code is the game. The best we can do is to attempt to handle modifications to the game design gracefully.
The most obvious case of this is the state machines that we saw from Chapter 4, Artificial Intelligence using the State Pattern. The states often need access to the Object Manager and so scan the entire list of objects looking for an object. They may also need access to physics to see if they are colliding ...
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