Fix wave notification text

This commit is contained in:
2024-02-13 16:18:10 +01:00
parent a97086e5a4
commit f066ae1b3d
3 changed files with 10 additions and 6 deletions

View File

@@ -616,7 +616,10 @@ static void renderGame(Game *game, float dt) {
static f32 waveDisplay = 0.0f;
if (isWaveOver(&game->waveInfo)) {
game->waveInfo = getWaveInfo(&game->waves, game->waveInfo.number + 1);
waveDisplay = 1.6f;
}
if (game->waveInfo.number > 0 && game->waveInfo.started &&
game->waveInfo.elapsed - game->waveInfo.data.timeBeforeStart < 1.0f) {
waveDisplay = 0.6f;
}
if (waveDisplay > 0.0f) {

View File

@@ -83,7 +83,7 @@ void drawGameUI(Game *game, f32 dt) {
i32 min = startingIn / 60.0f;
i32 sec = startingIn - (min * 60);
snprintf(waveDisplay, sizeof(waveDisplay), "Wave %d starting in: %02d:%02d ",
game->waveInfo.number + 1, min, sec);
game->waveInfo.number, min, sec);
}
uiBaseLabel(waveDisplay, game->font, 0.5f, WHITE);
bzUIPopParent(UI); // topBarRight

View File

@@ -4,11 +4,12 @@
#include "entity_factory.h"
#include "utils.h"
#define NUM_WAVES 14
#define NUM_WAVES 15
EnemyWaves getDefaultWaves() {
static WaveData waves[NUM_WAVES] = {
{ 0, 0.0f, 5, 1.0f, 0, 8 * 60 },
{ 0, 0.0f, 0, 0.0f, 0, 0}, // Dummy wave
{ 0, 0.0f, 5, 1.0f, 0, 8 * 60},
{ 0, 0.0f, 20, 2.0f, 0, 3 * 60 },
{ 5, 0.2f, 30, 2.2f, 0, 60 },
{ 10, 0.5f, 40, 2.4f, 0, 40 },
@@ -75,7 +76,7 @@ void updateWave(WaveInfo *wave, Game *game, f32 dt) {
wave->goblinsElapsed += dt;
f32 timeForGoblin = 1.0f / wave->data.goblinSendRate;
while (wave->goblinsElapsed >= timeForGoblin) {
while (wave->goblinsToSend > 0 && wave->goblinsElapsed >= timeForGoblin) {
Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20);
entityCreate(ENTITY_GOBLIN, spawnPos, PLAYER_ENEMY, game);
wave->goblinsElapsed -= timeForGoblin;
@@ -83,7 +84,7 @@ void updateWave(WaveInfo *wave, Game *game, f32 dt) {
}
f32 timeForOrc = 1.0f / wave->data.orcSendRate;
while (wave->orcsElapsed >= timeForOrc) {
while (wave->orcsToSend > 0 && wave->orcsElapsed >= timeForOrc) {
Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20);
entityCreate(ENTITY_ORC, spawnPos, PLAYER_ENEMY, game);
wave->orcsElapsed -= timeForOrc;