Chapter 3. Working with Game Objects

All games have objects, for example, players, enemies, non-player character (NPC), traps, bullets, and doors. Keeping track of all these objects and how they interact with each other is a big task and one that we would like to make as simple as possible. Our game could become unwieldy and difficult to update if we do not have a solid implementation. So what can we do to make our task easier? We can start by really trying to leverage the power of object-oriented programming (OOP). We will cover the following in this chapter:

  • Using inheritance
  • Implementing polymorphism
  • Using abstract base classes
  • Effective inheritance design

Using inheritance

The first powerful feature of OOP we will look at is inheritance. This feature ...

Get SDL Game Development 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.