summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-09-15 00:53:24 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-09-15 00:53:24 +0400
commitafcf5dd75841ace0be6e1c59d9b7769a4170d50b (patch)
treeea078dd7b699c0c40c02b03a665a3bfb4cf30203
parent5be3c38211c6e236fdf39c2885da571d93ad32ae (diff)
Added new entities in loadScene
-rw-r--r--src/main.c38
-rw-r--r--src/storage.c4
-rw-r--r--src/storage.h4
3 files changed, 33 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index b82308e..b46b16d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,7 @@ sys_collide(storage_t *storage, entity_t eid)
{
printf("Inside collide, id = %i\n", eid);
transform_t *transform = GET_COMPONENT(storage, transform_t, eid);
- collider_t *collider = GET_COMPONENT(storage, collider_t, eid);
+ // collider_t *collider = GET_COMPONENT(storage, collider_t, eid);
printTransform(transform);
printf("\n");
}
@@ -86,17 +86,17 @@ loadScene(storage_t *storage)
entity_t e1 = createEntity(storage);
ADD_COMPONENT(storage, e1, transform_t);
- ADD_COMPONENT(storage, e1, collider_t);
+ // ADD_COMPONENT(storage, e1, collider_t);
transform_t *t1 = GET_COMPONENT(storage, transform_t, e1);
t1->x = 13;
t1->y = 37;
// printTransform(t1);
- collider_t *c1 = GET_COMPONENT(storage, collider_t, e1);
- c1->height = 50;
- c1->width = 50;
- c1->collisionsCount = 5;
+ // collider_t *c1 = GET_COMPONENT(storage, collider_t, e1);
+ // c1->height = 50;
+ // c1->width = 50;
+ // c1->collisionsCount = 5;
entity_t e2 = createEntity(storage);
ADD_COMPONENT(storage, e2, transform_t);
@@ -110,10 +110,30 @@ loadScene(storage_t *storage)
ADD_COMPONENT(storage, e3, transform_t);
transform_t *t3 = GET_COMPONENT(storage, transform_t, e3);
- t3->x = 228;
- t3->y = 123;
+ t3->x = 123;
+ t3->y = 456;
// printTransform(t3);
+ entity_t e4 = createEntity(storage);
+ ADD_COMPONENT(storage, e4, transform_t);
+
+ transform_t *t4 = GET_COMPONENT(storage, transform_t, e4);
+ t4->x = 1212;
+ t4->y = 1212;
+
+ entity_t e5 = createEntity(storage);
+ ADD_COMPONENT(storage, e5, transform_t);
+
+ transform_t *t5 = GET_COMPONENT(storage, transform_t, e5);
+ t5->x = 888;
+ t5->y = 888;
+
+ printTransform(t1);
+ printTransform(t2);
+ printTransform(t3);
+ printTransform(t4);
+ printTransform(t5);
+
{
char *components[] = {"transform_t", "collider_t", NULL};
bitset_t bitset = createSignature(storage, components);
@@ -156,7 +176,7 @@ main()
storage_t storage;
initStorage(&storage);
loadScene(&storage);
- update(&storage);
+ // update(&storage);
return 0;
}
diff --git a/src/storage.c b/src/storage.c
index 1935ae7..b5b50ec 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -69,7 +69,7 @@ internal_registerComponent(storage_t *storage, const char *name, size_t size)
};
}
-void * // NULL if component with such name is not found
+char * // NULL if component with such name is not found
internal_addComponent(storage_t *this, entity_t idx, const char *name)
{
component_pair_t *pair = findPair(this, name);
@@ -86,7 +86,7 @@ internal_addComponent(storage_t *this, entity_t idx, const char *name)
}
// Not intended for use outside of macros
-void * // NULL if component is not found
+char * // NULL if component is not found
internal_getComponent(storage_t *this, entity_t idx, const char *name)
{
for (int i = 0; i < this->componentsStored; ++i)
diff --git a/src/storage.h b/src/storage.h
index 2601ef7..3edcdcf 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -61,11 +61,11 @@ void
internal_registerComponent(storage_t *storage, const char *name, size_t size);
// Not intended for use outside of macros
-void * // NULL if component with such name is not found
+char * // NULL if component with such name is not found
internal_addComponent(storage_t *this, entity_t idx, const char *name);
// Not intended for use outside of macros
-void * // NULL if component is not found
+char * // NULL if component is not found
internal_getComponent(storage_t *this, entity_t idx, const char *name);
#endif // storage_h_INCLUDED