summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 2285802b6b2affceeff3057bbf5b722455915448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
}