diff --git a/game/wave.c b/game/wave.c index 5f3d75c..a947aff 100644 --- a/game/wave.c +++ b/game/wave.c @@ -4,15 +4,24 @@ #include "entity_factory.h" #include "utils.h" -#define NUM_WAVES 5 +#define NUM_WAVES 14 EnemyWaves getDefaultWaves() { static WaveData waves[NUM_WAVES] = { - { 10, 1.0f, 20, 2.0f, 0, 5 * 60 }, - { 20, 1.0f, 40, 2.0f, 0, 2 * 60 }, - { 25, 1.0f, 80, 2.2f, 0, 2 * 60 }, - { 50, 1.2f, 120, 3.0f, 0, 1.5f * 60 }, - { 100, 2.0f, 220, 4.0f, 0, 1.0f * 60 }, + { 0, 0.0f, 5, 1.0f, 0, 5 * 60 }, + { 0, 0.0f, 20, 2.0f, 0, 1.5f * 60 }, + { 5, 0.2f, 30, 2.2f, 0, 30 }, + { 10, 0.5f, 40, 2.4f, 0, 20 }, + { 20, 1.0f, 60, 2.6f, 0, 20 }, + { 40, 1.4f, 80, 2.8f, 0, 10 }, + { 60, 1.5f, 100, 3.0f, 0, 10 }, + { 80, 1.6f, 120, 3.2f, 0, 10 }, + { 100, 1.8f, 160, 3.4f, 0, 5 }, + { 120, 2.0f, 200, 3.5f, 0, 5 }, + { 180, 2.2f, 250, 3.8f, 0, 5 }, + { 220, 2.5f, 300, 4.0f, 0, 5 }, + { 250, 3.0f, 350, 4.2f, 0, 5 }, + { 300, 4.0f, 400, 4.5f, 0, 5 }, }; return (EnemyWaves) { .numWaves = NUM_WAVES, @@ -38,6 +47,7 @@ WaveInfo getWaveInfo(const EnemyWaves *waves, i32 idx) { } else { waveData = waves->waves[idx]; + waveData.timeBeforeStart = waves->waves[NUM_WAVES - 1].timeBeforeStart; } WaveInfo info = { @@ -46,7 +56,6 @@ WaveInfo getWaveInfo(const EnemyWaves *waves, i32 idx) { .orcsToSend = waveData.numOrcs, .goblinsToSend = waveData.numGoblins, }; - info.data.timeBeforeStart /= 60; return info; } @@ -66,17 +75,19 @@ void updateWave(WaveInfo *wave, Game *game, f32 dt) { wave->goblinsElapsed += dt; f32 timeForGoblin = 1.0f / wave->data.goblinSendRate; - if (wave->goblinsElapsed >= timeForGoblin) { + while (wave->goblinsElapsed >= timeForGoblin) { Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20); entityCreate(ENTITY_GOBLIN, spawnPos, PLAYER_ENEMY, game); wave->goblinsElapsed -= timeForGoblin; + wave->goblinsToSend--; } f32 timeForOrc = 1.0f / wave->data.orcSendRate; - if (wave->orcsElapsed >= timeForOrc) { + while (wave->orcsElapsed >= timeForOrc) { Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20); entityCreate(ENTITY_ORC, spawnPos, PLAYER_ENEMY, game); wave->orcsElapsed -= timeForOrc; + wave->orcsToSend--; } }