Game Engine Design

The inheritance engine is starting to become very functional as components can be linked with certain objects via references. The component has three functions that should be present within all of the sub classes. A component may have to render and the component may have to do handle some processes. When a component call the link method is simple connects with other components in case it needs to rely on it’s resources. Example a sprite component needs to link with a transform component because sprites need to know in what position, rotation and scale they should be drawn.

As you can see for inheritance the object isn’t just a simple unique identifier with the component references or types that it looks for. Rather it holds a map of components that is linked to a certain type index.

At runtime each object loops through the set of components they have attached and then render or process those components. There is a lot of things to take into consideration when doing these functions. Each component that is mapped to a specific key needs to ensure that it isn’t attached twice along with making sure that all components get deleted from it’s reference and removed from the map when an object is destroyed.

This system overall has worked really well and there are no compile time and runtime errors.

The component can easily be inherited into a sub class for unique functionality as shown below:

Once an object is specified it can be added to a scene and the main engine will do the rest of the work from there:

Over the next week work will start for the main engine that does the entity component system. I will see if it is not too much time on my hands.

Add a Comment

Your email address will not be published. Required fields are marked *