diff --git a/README.md b/README.md index 74f8400..517909a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # 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. +A header only library implementing the data structures for an Entity-Component-System in C89 using memory arenas. -## Demo (Particle System) +## Example 1 (Simple Particle System) ->[!TODO] Add Video +![Demo Example 1](./images/BECSdemoexample1.webp) ## Instructions on Usage -Include `becs.h` and in exactly one file define `BECS_IMPLEMENTATION` before the include. +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` @@ -29,5 +29,12 @@ int main(void) ## 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) +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](./examples/example1/example1.c) 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](./images/BECSdemoexample1NoRenderer.webp) + +As you can see above, without the renderer at 100000 entities, the simulation is running at around 2800 FPS or 0.3ms. diff --git a/images/BECSdemoexample1.webp b/images/BECSdemoexample1.webp new file mode 100644 index 0000000..dcfc7ee Binary files /dev/null and b/images/BECSdemoexample1.webp differ diff --git a/images/BECSdemoexample1NoRenderer.webp b/images/BECSdemoexample1NoRenderer.webp new file mode 100644 index 0000000..fc4b5a6 Binary files /dev/null and b/images/BECSdemoexample1NoRenderer.webp differ