How to use the ECS
This ECS can be used for any purpose, like creating video games, or mobile applications, ect.
A basic implementation would be:
int main() {
Registry reg;
reg.register_component<Position>();
Entity e = reg.spawn_entity();
Position pos = {1, 2};
reg.add_component<Position>{pos, e};
}
I will explain line per line how this works:
Here we create a new Registry object. We register the Position component in the registry, so that we can add a Position component to our future entities. We create a new Entity, made by the Registry, and is also added to every SparseArray already created. We create a Position component. We set the Position component we created earlier to the Entity.The position of the Entity can now be retrieved using:
reg.get_components<Position>()[e()];