#include #include #include #include "storage.h" typedef struct { int x; int y; } Transform; void printTransform(Transform *t) { printf("Transform { .x = %i, .y = %i }\n", t->x, t->y); } typedef struct { float width; float height; int collisionsCount; } Collider; void initStorage(storage *storage) { storage->componentsStored = 0; storage->objectsStored = 0; storage->objects = (component_pair *) malloc(MAX_COMPONENTS * sizeof(component_pair)); REGISTER_COMPONENT(storage, Transform); REGISTER_COMPONENT(storage, Collider); } void loadScene(storage *storage) { Entity e1 = createEntity(storage); ADD_COMPONENT(storage, e1, Transform); Transform *t1 = GET_COMPONENT(storage, Transform, e1); if (t1 == NULL) { printf("t1 is NULL\n"); } else { printf("t1 is NOT NULL\n"); t1->x = 13; t1->y = 37; printTransform(t1); } } int main() { storage storage; initStorage(&storage); loadScene(&storage); return 0; }