Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork562
A fast entity component system (ECS) for C & C++
License
SanderMertens/flecs
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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:
- Fast andportable zero dependencyC99 API
- Modern type-safeC++17 API that doesn't use STL containers
- First open source ECS with full support forEntity Relationships!
- Fast native support forhierarchies andprefabs
- Code base that builds in less than 5 seconds
- Runsin the browser without modifications with emscripten
- Cache friendlyarchetype/SoA storage that can process millions of entities every frame
- Automatic component registration that works out of the box across shared libraries/DLLs
- Write free functions withqueries or run code automatically insystems
- Run games on multiple CPU cores with a fast lockless scheduler
- Verified on all major compilers and platforms withCI running more than 10000 tests
- Integratedreflection framework withJSON serializer and support forruntime components
- Unit annotations for components
- Powerfulquery language with support forjoins andinheritance
- Statistics addon for profiling ECS performance
- A web-based UI for monitoring & controlling your apps:
To support the project, give it a star 🌟 !
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:
- Hasentities that uniquely identify objects in a game
- Hascomponents which are datatypes that can be added to entities
- Hassystems which are functions that run for all entities matching a componentquery
For more information, check theECS FAQ!
C99 example:
typedefstruct {floatx,y;}Position,Velocity;voidMove(ecs_iter_t*it) {Position*p=ecs_field(it,Position,0);Velocity*v=ecs_field(it,Velocity,1);for (inti=0;i<it->count;i++) {p[i].x+=v[i].x;p[i].y+=v[i].y; }}intmain(intargc,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_te=ecs_insert(ecs,ecs_value(Position, {10,20}),ecs_value(Velocity, {1,2}));while (ecs_progress(ecs,0)) { }}
Same example in C++:
structPosition {float x, y;};structVelocity {float x, y;};intmain(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()) { }}
If you have a project you'd like to share, let me know onDiscord!
https://github.com/SanderMertens/tower_defense
https://github.com/flecs-hub/city
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 |
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!
About
A fast entity component system (ECS) for C & C++
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
















