#include "spawner.h" #include "standard.h" #include "wave.h" #include "world.h" static const Wave waves[] = { { { { 20, 2, { { 3, 5 }, { 15, 15 } } } }, 1, 2 }, { { { 20, 2, { { 3, 5 }, { 15, 15 } } }, { 200, 4, { { 30, 30 }, { 15, 20 }, { 23, 5 }, { 6, 4 } } }, }, 2, 6 }, { { { 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 } }; 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; }