A fast entity component system (ECS) for C & C++
Find a file
2026-02-17 20:18:27 -08:00
.github #1923 Don't create member entities when using C++ component::member API 2026-01-29 17:06:15 -08:00
cmake #1803 Fix compiler error when using set/assign with non-copyable type, update to C++17 2025-09-23 16:58:43 -07:00
distr Fix issue with updating parent record administration 2026-02-17 17:13:26 -08:00
docs #1898 EntitiesComponents.md fixes 2026-02-16 20:11:35 -08:00
examples #1703 Add component tuple getters to C++ API 2026-02-06 11:24:52 -08:00
include #1947 Journaliing improvements 2026-02-17 16:30:54 -08:00
src Fix issue with updating parent record administration 2026-02-17 17:13:26 -08:00
templates Add custom_phases examples 2022-06-12 14:51:28 -07:00
test Add tests for prefab child id offsets 2026-02-17 20:18:27 -08:00
.bazelignore Fixing recursive bazel workspaces stepping on each other, updating to newer bake. 2021-03-05 09:51:04 -08:00
.bazelrc #1905 Update more parts of the API to C++17 2026-01-07 19:16:20 -08:00
.editorconfig #1353 Add CI spell checking using "typos" 2024-09-13 09:53:54 -07:00
.gitattributes #1294 Create .gitattributes 2024-08-06 22:53:53 -07:00
.gitignore Migrate bazel build to bzlmod 2024-08-22 04:09:59 +02:00
_typos.toml #1926 Add perlin noise and other math functions to flecs script 2026-02-02 19:02:30 -08:00
BUILD #1905 Update more parts of the API to C++17 2026-01-07 19:16:20 -08:00
CMakeLists.txt #1813 Correct dbghelp casing for MinGW cross-compilation 2025-09-28 16:27:24 -07:00
CMakePresets.json #1646 Add android support to cmake build 2025-05-06 20:20:51 -07:00
codecov.yaml #124 update codecov 2020-06-27 22:23:33 -07:00
LICENSE Add Flecs Systems video tutorial link, update README, LICENSE 2025-03-05 21:22:12 -08:00
meson.build #1908 New non-fragmenting hierarchy storage 2026-01-20 22:06:43 -08:00
meson_options.txt make the hello world example optional (#1074) 2023-12-04 22:45:58 -08:00
MODULE.bazel #1469 Fix CI bazel job 2024-12-11 14:35:03 -08:00
project.json #1804 Add Windows implementation for flecs_dump_backtrace 2025-09-23 19:46:59 -07:00
README.md Add dot(), normalize(), length(), length_sq() to script math 2026-02-04 20:55:21 -08:00
WORKSPACE #1469 Fix CI bazel job 2024-12-11 14:35:03 -08:00
WORKSPACE.bzlmod Migrate bazel build to bzlmod 2024-08-22 04:09:59 +02:00

flecs

Version MIT Documentation actions Discord Chat

Flecs is a fast and lightweight Entity Component System that lets you build games and simulations with millions of entities (join the Discord!). Here are some of the framework's highlights:

Flecs Explorer

To support the project, give it a star 🌟 !

What is an Entity Component System?

ECS is a way of organizing code and data that lets you build games that are larger, more complex and are easier to extend. Something is called an ECS when it:

  • Has entities that uniquely identify objects in a game
  • Has components which are datatypes that can be added to entities
  • Has systems which are functions that run for all entities matching a component query

For more information, check the ECS FAQ!

Show me the code!

C99 example:

typedef struct {
  float x, y;
} Position, Velocity;

void Move(ecs_iter_t *it) {
  Position *p = ecs_field(it, Position, 0);
  Velocity *v = ecs_field(it, Velocity, 1);

  for (int i = 0; i < it->count; i++) {
    p[i].x += v[i].x;
    p[i].y += v[i].y;
  }
}

int main(int argc, char *argv[]) {
  ecs_world_t *ecs = ecs_init();

  ECS_COMPONENT(ecs, Position);
  ECS_COMPONENT(ecs, Velocity);

  ECS_SYSTEM(ecs, Move, EcsOnUpdate, Position, Velocity);

  ecs_entity_t e = ecs_insert(ecs,
    ecs_value(Position, {10, 20}),
    ecs_value(Velocity, {1, 2}));

  while (ecs_progress(ecs, 0)) { }
}

Same example in C++:

struct Position {
  float x, y;
};

struct Velocity {
  float x, y;
};

int main(int argc, char *argv[]) {
  flecs::world ecs;

  ecs.system<Position, const Velocity>()
    .each([](Position& p, const Velocity& v) {
      p.x += v.x;
      p.y += v.y;
    });

  auto e = ecs.entity()
    .insert([](Position& p, Velocity& v) {
      p = {10, 20};
      v = {1, 2};
    });

  while (ecs.progress()) { }
}

Projects using Flecs

If you have a project you'd like to share, let me know on Discord!

Tempest Rising

Tempest Rising

Territory Control 2

image

Resistance is Brutal

image

Rescue Ops: Wildfire

image

Age of Respair

image

FEAST

image

Gloam Vault

image

Antimatcher

image

Extermination Shock

image

The Forge

image

ECS survivors

image

Ascendant

image

Tome Tumble Tournament

image

Sol Survivor

image

Equilibrium Engine

image

After Sun

image

Flecs Demo's

https://github.com/SanderMertens/tower_defense Tower Defense

https://github.com/flecs-hub/city City

Flecs Hub

Flecs Hub is a collection of repositories that show how Flecs can be used to build game systems like input handling, hierarchical transforms and rendering.

Module Description
flecs.components.cglm Component registration for cglm (math) types
flecs.components.input Components that describe keyboard and mouse input
flecs.components.transform Components that describe position, rotation and scale
flecs.components.physics Components that describe physics and movement
flecs.components.geometry Components that describe geometry
flecs.components.graphics Components used for computer graphics
flecs.components.gui Components used to describe GUI components
flecs.systems.transform Hierarchical transforms for scene graphs
flecs.systems.physics Systems for moving objects and collision detection
flecs.systems.sokol Sokol-based renderer
flecs.game Generic game systems, like a camera controller

Language bindings

The following language bindings have been developed with Flecs! Note that these are projects built and maintained by helpful community members, and may not always be up to date with the latest commit from master!