Robotest
Jan. 10, 2019Behind the scenes
Entity Component System
Here's a hand made not so clear diagram of the architecture of the game engine. I'm currently working on this as a school project to make a game. This diagram represents what I've implemented so far. Let me make my views clear on this. Implementation of Entity Component System(ECS) varies & there's no exact implementation.
Previously I have implemented a component based architecture for the game engine which was working perfectly fine, with data driven, deserialised and all. But the problem with that architecture is that as you add functionalities and more and more game specific behaviours in this, it becomes tightly coupled. Whereas whole point of component based architecture is to have independent components tied to a single object instead of classic inheritance model which introduces complex annoying hierarchies. Plus, this architecture can't handle as many objects as an ECS can handle.
So to overcome all of this, I'm trying now to implement an Entity Component System(wiki) which will hopefully work out as I've expected. This system basically consists of three main parts; as the name suggests-
Entities - which is nothing but literally an " id " which represents each unique object in the game at a time.
Components - which are data packages: they are container which only contains raw data.
Systems - which has all the logic that defines behaviour of the object based on components they have.
Here systems play most important role. Each system is related with particular component, which they update every frame.
For example, Render system has relation only with transform and sprite components, so this system takes list of those components and update them according to its need(render in this case). Similarly, Physics System updates, let's say, Rigid Body Component. Moreover, systems won't have any idea about game objects at all.
One of the most important parts of any game engine, or even any systems, is memory management. I have implemented here a List-Map structure for object pool; about which I'll be writing soon. Also as I keep adding functionalities to this engine, I will keep sharing it. Until then, Peace!