Skip to main content
2 of 5
edited tags
user avatar
user avatar

Component based architecture: "pure" or some inheritance?

Until recently I programmed my games (simple ones) with a classic inheritance hierarchy. It worked fine.

But recently I learned the using a Component Based Architecture is more flexible in games. The idea is that the behavior of a game object isn't inherited from a superclass, but rather composed with the game object at runtime, allowing for different combinations of behvaviors.

Two questions:

1- Is my understanding of the Component Based Architecture approach correct?

2- When designing a game using this approach: Should I still use some inheritance? Some generic inheritance, such as:

 Entity / \ Player Enemy 

And on top of that, using a component approach?

Or should I not build any inheritance hierarchy at all? What is more recommended?

Aviv Cohn
  • 913
  • 2
  • 10
  • 27