Awesome Open Source
Awesome Open Source


Build Status codecov

ecs is the entity-component-system library I have created for my game Vagabond.

ecs aims to be:

  • easy to use
  • fast
  • lightweight
  • header only
  • implemented with modern C++ features (C++17)


Firstly, you should define some components:

struct Position : public Component<Position>
    float x;
    float y;

struct Velocity : public Component<Velocity>
    float x;
    float y;

A component of type T must inherit Component<T>.

Now, let us create an entity manager:

auto manager = EntityManager();

Next, let us create an entity with both components:

auto entity = manager.createEntity();

Finally, we can use getEntitySet to query all entities that have both components and update their positions:

auto dt = 1.0f / 60.0f;
for (auto [entity, components] : manager.getEntitySet<Position, Velocity>())
    auto [position, velocity] = components;
    // Update the position
    position.x += velocity.x * dt;
    position.y += velocity.y * dt;

It is that easy!

If you want more examples, look at the examples folder.


I have written several articles on my blog describing the design of the library. They are available here.

Otherwise, just look at the EntityManager.h file, it is simple to understand.


Distributed under the MIT License.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-plus-plus (18,765
cpp (1,336
game-development (483
header-only (156
ecs (131
entity-component-system (56
modern-cpp (50