Completing the Adventure Game
In Chapter 8, we started by creating a flexible health system that can be added to any object to give it health, take damage, and heal. The system is extensible, meaning the things that can deal with damage and apply healing can be anything without the need to modify the HealthSystem
class because we used interfaces to implement the behavior (not concrete class types). With objects now able to take damage, we continued by updating Player
and enemy objects to use health – so, we have the semblance of a real game in the making.
We continued by creating a wave spawner that instantiates new enemies on a fixed time interval and integrates with the existing patrol behavior. This allows us to add more complex enemy behavior, which adds new challenges to the game.
Finally, we further explored composition by refactoring some of our reusable components to explore a different approach to destroying the heal pickup object. The importance of good programming...