3 points super_puero | 2 comments | | HN request time: 0.429s | source
1. super_puero ◴[] No.44521845[source]
I’ve been working on a lightweight, header-only ECS called kawa::ecs that’s designed to be blazingly fast, minimal, and easy to use with modern C++20 features. If you’re building games, simulations, or AI systems and want a simple yet powerful ECS backbone, this might be worth checking out!

Quick example:

#include "registry.h" #include <string>

using namespace kawa::ecs;

struct Position { float x, y; }; struct Velocity { float x, y; }; struct Name { std::string name; };

int main() { registry reg(512);

    entity_id e = reg.entity();
    reg.emplace<Position>(e, 0.f, 0.f);
    reg.emplace<Velocity>(e, 1.f, 2.f);
    reg.emplace<Name>(e, "Bar");

    // Simple query
    reg.query
    (
        [](Position& p, Name* n)
        {
            std::cout << (n ? n->name : "unnamed") << " is at " << p.x << " " << p.y;
        }
    );

    float delta_time = 0.16;
    // Parallel query (multi-threaded)
    reg.query_par
    (
        [](float dt, Position& p, Velocity& v)
        {
            p.x += v.x * dt;
            p.y += v.y * dt;
        }
        , delta_time
    );
}