summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-09-11 13:48:08 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-09-11 13:48:08 +0400
commit259c4e23a136d2077c4083c4bbbad55a2a31bcef (patch)
treeee3670ece2d0b655d7167c4d3e5883ff895cfc5b /src/main.c
initial commit
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c64
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;
+}