-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplosions.c
60 lines (47 loc) · 1.05 KB
/
explosions.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
51
52
53
54
55
56
57
58
59
60
#include "explosions.h"
#include "explosion.h"
#include "list.h"
struct list *
explosions_new(void)
{
return list_new();
}
void
explosions_free(struct list *l)
{
list_free(l, (list_free_func) explosion_free);
}
void
explosions_update(void *object)
{
struct list *explosions;
struct node *n;
struct explosion *explosion;
explosions = (struct list *) object;
for (n = explosions->first; n; n = n->next) {
explosion_update(n->data);
explosion = n->data;
if (!explosion_alive(explosion)) {
list_remove(explosions, n);
explosion_free(explosion);
break;
}
}
}
void
explosions_draw(void *object, GLuint shader_program)
{
struct list *explosions;
struct node *n;
explosions = (struct list *) object;
for (n = explosions->first; n; n = n->next) {
explosion_draw(n->data, shader_program);
}
}
void
explosions_create(struct list *l, float x, float y, float z)
{
struct explosion *e;
e = explosion_new(x, y, z);
list_add(l, (void *) e);
}