-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoor.c
49 lines (42 loc) · 1.06 KB
/
door.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
#include "headers.h"
game_obj* newDoor(game_obj* list, float x, float y, float z)
{
game_obj* door = newListNode(list);
door->type = DOOR;
door->data = (float *)malloc(sizeof(float));
door->coords.x = x;
door->coords.y = y;
door->coords.z = z;
doorInit(door);
return door;
}
void doorInit(game_obj* a)
{
a->data[DOOR_CLOSED] = 1;
}
void doorTick(game_obj* a)
{
if(a->data[DOOR_CLOSED]) {
a->box.min.x = a->coords.x - 20; /* write bounding box */
a->box.min.y = a->coords.y - 20;
a->box.min.z = a->coords.z - 20;
a->box.max.x = a->coords.x + 20;
a->box.max.y = a->coords.y + 20;
a->box.max.z = a->coords.z + 20;
} else {
a->box.min.x = 0; /* empty bounding box */
a->box.min.y = 0;
a->box.min.z = 0;
a->box.max.x = 0;
a->box.max.y = 0;
a->box.max.z = 0;
}
}
void doorDraw(game_obj* a)
{
if(a->data[DOOR_CLOSED]) {
glTranslatef(a->coords.x / 10.0,
a->coords.y / 10.0, a->coords.z / 10.0);
drawModelWithGL(doorModel);
}
}