add whale

This commit is contained in:
2025-07-07 12:28:38 -04:00
parent 90ae6678c5
commit bbe2fa3553
5 changed files with 159 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
#include "Seaweed.h"
#include "Ship.h"
#include "Waterline.h"
#include "Whale.h"
#include <algorithm>
#include <iostream>
@@ -135,20 +136,26 @@ void Aquarium::addWaterline() { addEntityImpl<Waterline>(); }
void Aquarium::addCastle() { addEntityImpl<Castle>(); }
void Aquarium::addShip() { addEntityImpl<Ship>(); }
void Aquarium::addSeaMonster() { addEntityImpl<SeaMonster>(); }
void Aquarium::addWhale() { addEntityImpl<Whale>(); }
void Aquarium::ensureBigEntityExists() {
// Check if any big entities exist on screen
for (const auto &entity : entities) {
if (dynamic_cast<Ship *>(entity.get()) ||
dynamic_cast<SeaMonster *>(entity.get())) {
dynamic_cast<SeaMonster *>(entity.get()) ||
dynamic_cast<Whale *>(entity.get())) {
return; // Big entity found, do nothing
}
}
// No big entity found, spawn next in cycle
if (big_entity_index % 2 == 0) {
// No big entity found, spawn next in cycle (Ship, SeaMonster, Whale)
int entity_type = big_entity_index % 3;
if (entity_type == 0) {
addEntityImpl<Ship>();
} else {
} else if (entity_type == 1) {
addEntityImpl<SeaMonster>();
} else {
addEntityImpl<Whale>();
}
++big_entity_index;
}