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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#include "spawner.h"
#include "standard.h"
#include "wave.h"
#include "world.h"
static const Wave waves[] = {
/* 1 */
{
{
{
30,
2,
{
{ 3, 5 },
{ 15, 15 }
}
}
},
1,
2
},
/* 2 */
{
{
{
20,
2,
{
{ 3, 5 },
{ 15, 15 }
}
},
{
200,
4,
{
{ 30, 30 },
{ 15, 20 },
{ 23, 5 },
{ 6, 4 }
}
},
},
2,
6
},
/* 3 */
{
{
{
30,
3,
{
{ 30, 6 },
{ 29, 11 },
{ 11, 10 }
}
},
{
100,
3,
{
{ 7, 5 },
{ 20, 16 },
{ 27, 24 },
}
},
},
2,
6
},
/* 4 */
{
{
{
30,
2,
{
{ 6, 16 },
{ 18, 8 }
}
},
{
100,
2,
{
{ 12, 4 },
{ 27, 7 }
}
},
{
100,
2,
{
{ 11, 7 },
{ 21, 26 }
}
},
{
100,
2,
{
{ 2, 24 },
{ 14, 22 }
}
},
},
4,
8
},
/* 5 */
{
{
{
30,
3,
{
{ 20, 9 },
{ 21, 15 },
{ 23, 25 }
}
},
{
60,
3,
{
{ 21, 13 },
{ 1, 10 },
{ 24, 23 },
}
},
{
60,
2,
{
{ 9, 29 },
{ 30, 11 },
}
},
},
3,
8
},
};
void init_waver(Waver* waver) {
waver->idx = 0;
waver->sidx = 0;
waver->timer = 0;
}
void start_wave(struct World* world) {
world->wave_started = 1;
world->enemies_killed = 0;
}
int wave_enemy_count(const Waver* waver) {
return waves[waver->idx].kill_requirement;
}
void next_wave(Waver* waver) {
waver->idx++;
waver->sidx = 0;
}
void update_waver(Waver* waver, World* world) {
const Wave* wave;
const Subwave* subwave;
const Wave_Spawn* spawn;
int i;
wave = &waves[waver->idx];
subwave = &wave->subwaves[waver->sidx];
if (waver->sidx >= wave->subwave_count) { return; }
waver->timer++;
if (waver->timer >= subwave->frame) {
for (i = 0; i < subwave->count; i++) {
spawn = &subwave->spawns[i];
new_spawner(
world,
(spawn->x * map_tile_size) << fbits,
(spawn->y * map_tile_size) << fbits
);
}
waver->timer = 0;
waver->sidx++;
}
}
int get_wave_count() {
return sizeof waves / sizeof *waves;
}
|