becs/test/main.c

48 lines
894 B
C

#include <stdio.h>
#include <stdlib.h>
#define MAX_ENTITIES 100
#define NUM_COMPONENTS 2
#define BECS_IMPLEMENTATION
#include "../becs2.h"
typedef struct compA {
uint32_t thing;
} compA;
typedef struct compB {
uint32_t thing;
} compB;
int main(void) {
BECS_Properties EcsProps = {};
size_t componentSizes[2] = {
sizeof(compA),
sizeof(compB),
};
for (uint32_t i = 0; i < NUM_COMPONENTS; i++)
{
EcsProps.componentSizes[i] = componentSizes[i];
}
size_t MinMemorySize = BECS_GetMinMemorySize(EcsProps);
printf("%llu\n", MinMemorySize);
BECS_ECS *ecs = malloc(MinMemorySize);
BECS_Init(ecs, MinMemorySize, EcsProps);
uint32_t entityID = 0;
compA *component = (compA *)BECS_AddComponent(ecs, entityID, 0);
component->thing = 1;
compA *component2 = (compA *)BECS_GetComponent(ecs, entityID, 0);
BECS_RemoveComponent(ecs, entityID, 0);
printf("Initialized\n");
}