Wave incrementing

This commit is contained in:
2024-02-11 19:23:40 +01:00
parent 0319a0a5b3
commit bfc1bc425f
7 changed files with 73 additions and 10 deletions

View File

@@ -480,6 +480,8 @@ void update(float dt, void *userData) {
break;
}
updateWave(&game->waveInfo, dt);
SoundState *soundState = ecs_singleton_get_mut(ECS, SoundState);
soundsUpdate(soundState, getCameraBounds(game->camera));
}
@@ -605,9 +607,30 @@ static void renderGame(Game *game, float dt) {
if (game->debug.drawSpatialGrid)
bzSpatialGridDrawDebugGrid(game->entityGrid);
drawPlayerInputUI();
EndMode2D();
static f32 waveDisplay = 0.0f;
if (isWaveOver(&game->waveInfo)) {
game->waveInfo = getWaveInfo(game->waveInfo.number + 1);
waveDisplay = 1.6f;
}
if (waveDisplay > 0.0f) {
const i32 fontSize = 72 * uiGetScale();
char text[32];
snprintf(text, sizeof(text), "Wave: %d", game->waveInfo.number);
Vector2 textSize = MeasureTextEx(game->font, text, fontSize, 1.0f);
i32 x = GetScreenWidth() * 0.5f - textSize.x * 0.5f;
i32 y = GetScreenHeight() * 0.5f - textSize.y;
Color color = WHITE;
const f32 fadeAt = 0.45f;
if (waveDisplay < fadeAt)
color.a = (waveDisplay / fadeAt) * 255;
DrawText(text, x, y, fontSize, color);
waveDisplay -= dt;
}
#if 0
static bool firstRun = true;
if (firstRun) {
editedEmitter = GET_BLOOD_EMITTER();
@@ -623,6 +646,7 @@ static void renderGame(Game *game, float dt) {
ecs_set_ptr(ECS, e, ParticleEmitter, &emitter);
}
#endif
}
void render(float dt, void *userData) {