collision map
This commit is contained in:
@@ -37,7 +37,7 @@ auto RoomSaver::conveyorBeltToString(int direction) -> std::string {
|
||||
|
||||
// Genera el YAML completo como texto con formato compacto
|
||||
auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& room_data) -> std::string { // NOLINT(readability-function-cognitive-complexity)
|
||||
(void)original_yaml; // Ya no se usa; mantenido para compatibilidad con la firma de saveYAML
|
||||
(void)original_yaml; // Ya no se usa; mantenido para compatibilidad con la firma de saveYAML
|
||||
std::ostringstream out;
|
||||
|
||||
// --- Sección room ---
|
||||
@@ -70,10 +70,13 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
|
||||
// --- Tilemap (MAP_HEIGHT filas × MAP_WIDTH columnas, formato flow) ---
|
||||
out << "\n";
|
||||
out << "# Tilemap: " << Map::HEIGHT << " filas x " << Map::WIDTH << " columnas @ " << Tile::SIZE << "px/tile\n";
|
||||
out << "# Índices de tiles (-1 = vacío)\n";
|
||||
out << "tilemap:\n";
|
||||
|
||||
// Mapa de dibujo
|
||||
out << " # Mapa de dibujo (indices de tiles, -1 = vacio)\n";
|
||||
out << " draw:\n";
|
||||
for (int row = 0; row < Map::HEIGHT; ++row) {
|
||||
out << " - [";
|
||||
out << " - [";
|
||||
for (int col = 0; col < Map::WIDTH; ++col) {
|
||||
int index = (row * Map::WIDTH) + col;
|
||||
if (index < static_cast<int>(room_data.tile_map.size())) {
|
||||
@@ -86,6 +89,23 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
|
||||
out << "]\n";
|
||||
}
|
||||
|
||||
// Mapa de colisiones
|
||||
out << " # Mapa de colisiones (0 = vacio, 1 = solido)\n";
|
||||
out << " collision:\n";
|
||||
for (int row = 0; row < Map::HEIGHT; ++row) {
|
||||
out << " - [";
|
||||
for (int col = 0; col < Map::WIDTH; ++col) {
|
||||
int index = (row * Map::WIDTH) + col;
|
||||
if (index < static_cast<int>(room_data.collision_tile_map.size())) {
|
||||
out << room_data.collision_tile_map[index];
|
||||
} else {
|
||||
out << 0;
|
||||
}
|
||||
if (col < Map::WIDTH - 1) { out << ", "; }
|
||||
}
|
||||
out << "]\n";
|
||||
}
|
||||
|
||||
// --- Enemigos ---
|
||||
if (!room_data.enemies.empty()) {
|
||||
out << "\n";
|
||||
|
||||
Reference in New Issue
Block a user