I have decided to add an ECS (Entity Component System) to Beep8.
I am making an adventure game maker and wanted to have emergent gameplay where objects can behave and interact with each other. I didn’t know how to do this, so did a lot of research and found out that an ECS would be a good fit.
ECS stands for Entity Component System. Using an ECS an entity is an object in the game world. A component is a piece of data that can be attached to an entity, like position, velocity, health, or a sprite. A system is a piece of code that runs every frame and updates entities that have certain components.
So, components hold data, and different entities can have similar components. For example, both a player and an enemy, and an NPC (non-player character) will have position/ location and sprite components. They can have a system that renders them to the screen. Traditionally I would have a list of player characters, enemies and NPCs and loop through each list to render them. This already simplifies things a lot.
But there’s more than this. Another example is I can have a “pushable” component that could be added to any entity that can be pushed around, and the push system will automatically handle everything. So I can easily add new objects and then decide I want them to be pushable, and just add the component without needing to change/ add any code.