Home

Awesome

Actions Status License: MIT

Met ECS

A simple Entity Component System library made for learning purposes. It is header-only, so just have to copy the content of the src folder and include <met/met.hpp> to check it out. It does require a C++ 17 version of your compiler though.


Made by students, the project purposes are to be easy to understand and thoroughly documented. It is seen as an entry point for users and developers. We provide both a post-mortem to explain the inner-working of the library, and many exercices to get started with ECS.

The API is heavly based on ENTT by skypjack, you should check it out if you're looking for a highly performant and production-ready library.

Violets are blue, roses are red, and when I met ecs, my world rebooted 🌐

Table of Contents

Introduction

What is ECS ?

ECS (Entity Component System) is way to organize your data and your logic which radicaly changes from traditional Object-Oriented Programming. It is seen as both a way to improve performance and to ease maintenance. Well-suited for games, it is designed to handle operations on large groups.

ECS is made out of 3 pieces that can be summarized with these simple rules :

Code Example

#include <met/met.hpp>

struct Position {
    float x;
    float y;
};

struct Velocity {
    float dx;
    float dy;
};

int main() {
    met::registry registry;
    auto entity = registry.create();
    
    Position pos = { 2, 3 };
    registry.assign<position>(entity, pos);
    
    Velocity vel = { 5, 8 };
    registry.assign<position>(entity, vel);
    
    registry.view<Position, Velocity>().each([](met::entity id, Position& pos, Velocity& vel) {
        pos.x += 2;
        std::cout << "pos " << pos.x << " " << pos.y << std::endl;
        std::cout << "vel " << vel.dx << " " << vel.dy << std::endl;
    });

    // ...
}

Learn

Use an ECS library

Some exercices has been created to use ECS step by step.

Create an ECS library

The post-mortem offers a view on ECS possible implementations and explain everything there is to know about this library.

Build unit tests

Prerequisites

You need to have CMake and a C++ compiler which handles C++ 17.

Linux

sudo apt-get install build-essential cmake

Windows

You can install Visual Studio to get the MSVC compiler, and you can download CMake from their website.

External links

FAQs

Videos

Articles

Libraries