Entity Management with Components

Hello, my current task for my game engine is to write a system for managing the games entities. I've read up about the component design pattern and it seems like the path I would like to take. What I'm curious about is how I would start to implement this. I wrote out something on paper and I'm not sure how well it will work out... but here it goes anyway.

The BaseObject class provides a very basic interface for the games entities such as methods for event handling, updating, and drawing. BaseObject is a template class which is told what components to use via the template parameters. Is it possible to use an array of some sort to hold a list of components? For example, you could create a zombie entity like class Zombie : public BaseObject<Components::RENDER, Components::MOVEMENT, Components::PHYSICS, Components::SCRIPT> etc, etc.
The components enumeration holds the values.

The update function of BaseObject would simply check the array to see what types of components are passed and then call a function from each components class.

I'm not sure if this is complete non-sense or something, if it is I would appreciate any help I can get on this. Thanks a lot!
Last edited on
In order to store these things polymorphically, they will all need to have the same template parameters in their BaseObject "part". So the part about the "update function..." does not make sense to me.
Topic archived. No new replies allowed.