A simple Entity-Component-System (ECS) that is implemented using Memory Arenas
Go to file
2026-01-24 22:44:07 +08:00
examples/example1 Update: build script and add comment in example1.bat 2026-01-23 15:41:35 +08:00
images Add: images and README.md 2026-01-24 14:13:27 +08:00
test Update: make some linux specific changes 2026-01-22 20:50:56 +08:00
.clangd Update: Implement becs3.h in C89 2026-01-21 17:15:51 +08:00
.editorconfig Update: Implement becs3.h in C89 2026-01-21 17:15:51 +08:00
.gitignore initial commit 2026-01-16 17:36:44 +08:00
.gitmodules Fix: becs.h had a few bugs that I didn't catch around deleting entities 2026-01-22 18:05:43 +08:00
becs.h Update: switch over to all arrays being allocated by my own memory arena. Prevents stack overflow for high entity counts 2026-01-23 16:37:29 +08:00
build.bat Update: Change build script to have a run option 2026-01-22 10:49:56 +08:00
build.sh Update build.sh 2026-01-22 08:22:03 +08:00
LICENSE Update: rename License file 2026-01-24 22:44:07 +08:00
README.md Add: images and README.md 2026-01-24 14:13:27 +08:00

Barcelli Entity-Component-System (BECS)

A header only library implementing the data structures for an Entity-Component-System in C89 using memory arenas.

Example 1 (Simple Particle System)

Demo Example 1

Instructions on Usage

Include becs.h and in exactly one file #define BECS_IMPLEMENTATION before the include.

To setup your Maximum Entity Count and Maximum component count, define BECS_MAX_ENTITIES and BECS_MAX_COMPONENTS before including becs.h

Example:

#define BECS_MAX_ENTITIES 100
#define BECS_MAX_COMPONENTS 10

#define BECS_IMPLEMENTATION
#include <becs.h>

int main(void)
{
    /* your program goes here */
}

Systems

To get best performance out of systems, you should try to iterate across the dense arrays in each component pool. Take a look at Example 1's implementation of systems.

[!NOTE] The renderer is a big limiting factor in this example as I didn't try to hard to optimize it past batch rendering the particles. See below

Example 1 Without Renderer:

Without Renderer

As you can see above, without the renderer at 100000 entities, the simulation is running at around 2800 FPS or 0.3ms.