polimorfise d'enemics

moving platforms
This commit is contained in:
2026-04-08 14:09:28 +02:00
parent 5e02854e7a
commit 73a520bf3c
20 changed files with 632 additions and 106 deletions

View File

@@ -112,6 +112,7 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
out << "enemies:\n";
for (const auto& enemy : room_data.enemies) {
out << " - animation: " << enemy.animation_path << "\n";
if (enemy.type != "path") { out << " type: " << enemy.type << "\n"; }
int pos_x = static_cast<int>(std::round(enemy.x / Tile::SIZE));
int pos_y = static_cast<int>(std::round(enemy.y / Tile::SIZE));
@@ -155,6 +156,33 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
}
}
// --- Plataformas ---
if (!room_data.platforms.empty()) {
out << "# Plataformas móviles en esta habitación\n";
out << "platforms:\n";
for (const auto& plat : room_data.platforms) {
out << " - animation: " << plat.animation_path << "\n";
int pos_x = static_cast<int>(std::round(plat.x / Tile::SIZE));
int pos_y = static_cast<int>(std::round(plat.y / Tile::SIZE));
out << " position: {x: " << pos_x << ", y: " << pos_y << "}\n";
out << " velocity: {x: " << plat.vx << ", y: " << plat.vy << "}\n";
int b1_x = plat.x1 / Tile::SIZE;
int b1_y = plat.y1 / Tile::SIZE;
int b2_x = plat.x2 / Tile::SIZE;
int b2_y = plat.y2 / Tile::SIZE;
out << " boundaries:\n";
out << " position1: {x: " << b1_x << ", y: " << b1_y << "}\n";
out << " position2: {x: " << b2_x << ", y: " << b2_y << "}\n";
if (plat.frame != -1) { out << " frame: " << plat.frame << "\n"; }
out << "\n";
}
}
return out.str();
}