diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..2285802 --- /dev/null +++ b/src/main.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#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; +} |