| examples/example1 | ||
| test | ||
| .clangd | ||
| .editorconfig | ||
| .gitignore | ||
| .gitmodules | ||
| becs.h | ||
| build.bat | ||
| build.sh | ||
| README.md | ||
Barcelli Entity-Component-System (BECS)
This is an header only library implementing a Entity-Component-System in C89 using memory arenas. You can look at tests/main.c for an example of an implementation. This is an educational library, done in my free time. If you are interested in improving the design of this ECS, feel free to submit a pull request. I am by no means an expert and ECS design, this was just a fun problem solving exercise.
Demo (Particle System)
[!TODO] Add Video
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
When writing systems try to write them such that you operate on the dense array of the individual components. Take a look at the implementation in example 1 for more detail. (Example 1's implementation lags at high particle counts due to my quick and shoddy writing of the render code. If you comment out the RenderSystem call in the loop, the ECS can handle 100000 entities being simulated at the same time with no issues)