#include #include #include #define BECS_MAX_ENTITIES 100 #define BECS_MAX_COMPONENTS 2 #define BECS_IMPLEMENTATION #include "../becs.h" typedef struct compA { uint32_t thing; } compA; typedef struct compB { uint32_t thing; } compB; enum { COMPA, COMPB }; int main(void) { size_t componentSizes[2] = { sizeof(compA), sizeof(compB), }; size_t MinMemorySize = BECS_GetMinMemoryArenaSize(componentSizes, 2); #ifdef _WIN32 printf("%llu\n", MinMemorySize); #endif #ifdef UNIX printf("%lu\n", MinMemorySize); #endif void *memory= malloc(MinMemorySize); BECS_ECS ecs = BECS_InitECS(memory, MinMemorySize); BECS_ComponentRegister(&ecs, sizeof(compA), BECS_MAX_ENTITIES); BECS_ComponentRegister(&ecs, sizeof(compB), BECS_MAX_ENTITIES); printf("Initialized\n"); BECS_Entity entity1 = BECS_EntityCreate(&ecs); BECS_Entity entity2 = BECS_EntityCreate(&ecs); BECS_ComponentAdd(&ecs, entity1, COMPA); BECS_ComponentAdd(&ecs, entity2, COMPB); bool testComponent1 = BECS_ComponentHas(&ecs, entity1, 0); bool testComponent2 = BECS_ComponentHas(&ecs, entity1, 1); bool testComponent3 = BECS_ComponentHas(&ecs, entity2, 0); bool testComponent4 = BECS_ComponentHas(&ecs, entity2, 1); if (testComponent1) { printf("Entity:%u has compA\n", entity1); } if (testComponent2) { printf("Entity:%u has compB\n", entity1); } if (testComponent3) { printf("Entity:%u has compA\n", entity2); } if (testComponent4) { printf("Entity:%u has compB\n", entity2); } return 0; }