-
Notifications
You must be signed in to change notification settings - Fork 0
/
System.c
executable file
·50 lines (36 loc) · 925 Bytes
/
System.c
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
#include "System.h"
#include <stdio.h>
#define MOVEMENT_MASK (COMPONENT_DISPLACEMENT | COMPONENT_VELOCITY)
void movementFunction(World *world)
{
unsigned int entity;
Displacement *d;
Velocity *v;
for(entity = 0; entity < ENTITY_COUNT; ++entity)
{
if((world->mask[entity] & MOVEMENT_MASK) == MOVEMENT_MASK)
{
d = &(world->displacement[entity]);
v = &(world->velocity[entity]);
v->y -= 0.98f;
d->x += v->x;
d->y += v->y;
}
}
}
#define RENDER_MASK (COMPONENT_DISPLACEMENT | COMPONENT_APPEARANCE)
void renderFunction(World *world)
{
unsigned int entity;
Displacement *d;
Appearance *a;
for(entity = 0; entity < ENTITY_COUNT; ++entity)
{
if((world->mask[entity] & RENDER_MASK) == RENDER_MASK)
{
d = &(world->displacement[entity]);
a = &(world->appearance[entity]);
printf("%s at (%f, %f)\n", a->name, d->x, d->y);
}
}
}