summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-09-12 20:21:28 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-09-12 20:21:28 +0400
commit5438fe938f6a15f4eadcc0bb2fd09a02130aafb4 (patch)
treef05d70112e40c255c225cb29d0d08853df633ae2 /src/main.c
parent259c4e23a136d2077c4083c4bbbad55a2a31bcef (diff)
Renamed most of structs and changed allocation strategy for storage
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/main.c b/src/main.c
index 2285802..ad50fd5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -8,10 +8,10 @@ typedef struct
{
int x;
int y;
-} Transform;
+} transform_t;
void
-printTransform(Transform *t)
+printTransform(transform_t *t)
{
printf("Transform { .x = %i, .y = %i }\n", t->x, t->y);
}
@@ -21,43 +21,39 @@ typedef struct
float width;
float height;
int collisionsCount;
-} Collider;
+} collider_t;
void
-initStorage(storage *storage)
+initStorage(storage_t *storage)
{
storage->componentsStored = 0;
storage->objectsStored = 0;
- storage->objects = (component_pair *) malloc(MAX_COMPONENTS * sizeof(component_pair));
+ storage->objects = (component_pair_t *) malloc(MAX_COMPONENTS * sizeof(component_pair_t));
- REGISTER_COMPONENT(storage, Transform);
- REGISTER_COMPONENT(storage, Collider);
+ REGISTER_COMPONENT(storage, transform_t);
+ REGISTER_COMPONENT(storage, collider_t);
}
void
-loadScene(storage *storage)
+loadScene(storage_t *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);
- }
+ entity_t e1 = createEntity(storage);
+ transform_t *t1 = GET_COMPONENT(storage, transform_t, e1);
+ t1->x = 13;
+ t1->y = 37;
+ printTransform(t1);
+
+ entity_t e2 = createEntity(storage);
+ transform_t *t2 = GET_COMPONENT(storage, transform_t, e2);
+ t2->x = 14;
+ t2->y = 88;
+ printTransform(t2);
}
int
main()
{
- storage storage;
+ storage_t storage;
initStorage(&storage);
loadScene(&storage);
return 0;