add sea monster
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "Bubble.h"
|
||||
#include "Castle.h"
|
||||
#include "Fish.h"
|
||||
#include "SeaMonster.h"
|
||||
#include "Seaweed.h"
|
||||
#include "Ship.h"
|
||||
#include "Waterline.h"
|
||||
@@ -46,6 +47,8 @@ void Aquarium::ensureEntitiesSorted() {
|
||||
void Aquarium::redraw() {
|
||||
clearCurrentFrame();
|
||||
|
||||
ensureBigEntityExists();
|
||||
|
||||
std::vector<std::unique_ptr<Entity>> newEntities;
|
||||
bool entities_modified = false;
|
||||
|
||||
@@ -93,7 +96,7 @@ void Aquarium::redraw() {
|
||||
|
||||
// Draw all entities
|
||||
for (const auto &entity : entities) {
|
||||
entity->draw(0);
|
||||
entity->draw();
|
||||
}
|
||||
|
||||
renderToScreen();
|
||||
@@ -119,7 +122,6 @@ void Aquarium::resize() {
|
||||
|
||||
addWaterline();
|
||||
addCastle();
|
||||
addShip();
|
||||
for (int i = 0; i < width / 15; i++)
|
||||
addSeaweed();
|
||||
for (int i = 0; i < width * (height - 9) / 350; i++)
|
||||
@@ -132,6 +134,24 @@ void Aquarium::addSeaweed() { addEntityImpl<Seaweed>(); }
|
||||
void Aquarium::addWaterline() { addEntityImpl<Waterline>(); }
|
||||
void Aquarium::addCastle() { addEntityImpl<Castle>(); }
|
||||
void Aquarium::addShip() { addEntityImpl<Ship>(); }
|
||||
void Aquarium::addSeaMonster() { addEntityImpl<SeaMonster>(); }
|
||||
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())) {
|
||||
return; // Big entity found, do nothing
|
||||
}
|
||||
}
|
||||
|
||||
// No big entity found, spawn next in cycle
|
||||
if (big_entity_index % 2 == 0) {
|
||||
addEntityImpl<Ship>();
|
||||
} else {
|
||||
addEntityImpl<SeaMonster>();
|
||||
}
|
||||
++big_entity_index;
|
||||
}
|
||||
|
||||
void Aquarium::clearCurrentFrame() {
|
||||
for (auto &row : currentFrame) {
|
||||
|
||||
Reference in New Issue
Block a user