Properly scale enemy wave health scale

This commit is contained in:
2024-02-15 22:18:04 +01:00
parent 9ca1992eef
commit fd999d63af
2 changed files with 14 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
mkdir build_web
pushd build_web || exit
emcmake cmake .. -DPLATFORM=Web
emcmake cmake -DPLATFORM=Web -DCMAKE_BUILD_TYPE=Release ..
emmake make
mv PixelDefense.html index.html

View File

@@ -44,7 +44,7 @@ WaveInfo getWaveInfo(const EnemyWaves *waves, i32 idx) {
WaveData waveData;
if (idx >= waves->numWaves) {
waveData = waves->waves[waves->numWaves - 1];
waveData.difficultyScale += (idx - waves->numWaves) * 0.1f;
waveData.difficultyScale += (idx - waves->numWaves) * 0.25f;
} else {
waveData = waves->waves[idx];
@@ -78,7 +78,12 @@ void updateWave(WaveInfo *wave, Game *game, f32 dt) {
f32 timeForGoblin = 1.0f / wave->data.goblinSendRate;
while (wave->goblinsToSend > 0 && wave->goblinsElapsed >= timeForGoblin) {
Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20);
entityCreate(ENTITY_GOBLIN, spawnPos, PLAYER_ENEMY, game);
ecs_entity_t e = entityCreate(ENTITY_GOBLIN, spawnPos, PLAYER_ENEMY, game);
ecs_set(ECS, e, Health, {
.startHP = 40.0f * (1 + wave->data.difficultyScale),
.hp = 40.0f * (1 + wave->data.difficultyScale),
.lastChanged = -1000.0f,
});
wave->goblinsElapsed -= timeForGoblin;
wave->goblinsToSend--;
}
@@ -86,7 +91,12 @@ void updateWave(WaveInfo *wave, Game *game, f32 dt) {
f32 timeForOrc = 1.0f / wave->data.orcSendRate;
while (wave->orcsToSend > 0 && wave->orcsElapsed >= timeForOrc) {
Vector2 spawnPos = randomizeSpawnPos(game->swarmSpawn, 20);
entityCreate(ENTITY_ORC, spawnPos, PLAYER_ENEMY, game);
ecs_entity_t e = entityCreate(ENTITY_ORC, spawnPos, PLAYER_ENEMY, game);
ecs_set(ECS, e, Health, {
.startHP = 80.0f * (1 + wave->data.difficultyScale),
.hp = 80.0f * (1 + wave->data.difficultyScale),
.lastChanged = -1000.0f,
});
wave->orcsElapsed -= timeForOrc;
wave->orcsToSend--;
}