continue amb els ambits

This commit is contained in:
2026-04-02 23:01:39 +02:00
parent 9ffd29bea8
commit 6faa80eef4
11 changed files with 199 additions and 109 deletions

View File

@@ -3,8 +3,8 @@
#include "game/editor/mini_map.hpp"
#include <algorithm> // Para std::max, std::min
#include <cmath> // Para std::floor
#include <array> // Para std::array
#include <cmath> // Para std::floor
#include <iostream> // Para cout
#include <map> // Para std::map
#include <queue> // Para queue (BFS)
@@ -18,7 +18,9 @@
#include "utils/utils.hpp" // Para stringToColor
// Constructor: construye todo el minimapa
MiniMap::MiniMap(Uint8 bg_color, Uint8 conn_color) : bg_color_(bg_color), conn_color_(conn_color) {
MiniMap::MiniMap(Uint8 bg_color, Uint8 conn_color)
: bg_color_(bg_color),
conn_color_(conn_color) {
buildTileColorTable("standard.gif");
layoutRooms();
buildRoomSurfaces();
@@ -217,8 +219,7 @@ void MiniMap::composeFinalSurface() {
if (!mini.surface) { continue; }
int px = cellPixelX(mini.pos.x) + SHADOW_OFFSET;
int py = cellPixelY(mini.pos.y) + SHADOW_OFFSET;
SDL_FRect shadow = {.x = static_cast<float>(px), .y = static_cast<float>(py),
.w = static_cast<float>(CELL_W), .h = static_cast<float>(CELL_H)};
SDL_FRect shadow = {.x = static_cast<float>(px), .y = static_cast<float>(py), .w = static_cast<float>(CELL_W), .h = static_cast<float>(CELL_H)};
map_surface_->fillRect(&shadow, COLOR_SHADOW);
}
@@ -229,13 +230,11 @@ void MiniMap::composeFinalSurface() {
int py = cellPixelY(mini.pos.y);
// Borde negro (la celda entera)
SDL_FRect cell = {.x = static_cast<float>(px), .y = static_cast<float>(py),
.w = static_cast<float>(CELL_W), .h = static_cast<float>(CELL_H)};
SDL_FRect cell = {.x = static_cast<float>(px), .y = static_cast<float>(py), .w = static_cast<float>(CELL_W), .h = static_cast<float>(CELL_H)};
map_surface_->fillRect(&cell, COLOR_ROOM_BORDER);
// Miniroom dentro del borde
SDL_FRect dst = {.x = static_cast<float>(px + BORDER), .y = static_cast<float>(py + BORDER),
.w = static_cast<float>(ROOM_W), .h = static_cast<float>(ROOM_H)};
SDL_FRect dst = {.x = static_cast<float>(px + BORDER), .y = static_cast<float>(py + BORDER), .w = static_cast<float>(ROOM_W), .h = static_cast<float>(ROOM_H)};
mini.surface->render(nullptr, &dst);
}
@@ -255,8 +254,7 @@ void MiniMap::drawConnections() {
if (room_data->right_room != "0" && !room_data->right_room.empty() && room_positions_.contains(room_data->right_room)) {
int x1 = px + CELL_W;
int y_mid = py + CELL_H / 2 - 1;
SDL_FRect line = {.x = static_cast<float>(x1), .y = static_cast<float>(y_mid),
.w = static_cast<float>(GAP), .h = 3.0F};
SDL_FRect line = {.x = static_cast<float>(x1), .y = static_cast<float>(y_mid), .w = static_cast<float>(GAP), .h = 3.0F};
map_surface_->fillRect(&line, conn_color_);
}
@@ -264,8 +262,7 @@ void MiniMap::drawConnections() {
if (room_data->lower_room != "0" && !room_data->lower_room.empty() && room_positions_.contains(room_data->lower_room)) {
int x_mid = px + CELL_W / 2 - 1;
int y1 = py + CELL_H;
SDL_FRect line = {.x = static_cast<float>(x_mid), .y = static_cast<float>(y1),
.w = 3.0F, .h = static_cast<float>(GAP)};
SDL_FRect line = {.x = static_cast<float>(x_mid), .y = static_cast<float>(y1), .w = 3.0F, .h = static_cast<float>(GAP)};
map_surface_->fillRect(&line, conn_color_);
}
}
@@ -309,8 +306,7 @@ void MiniMap::render(const std::string& current_room) {
// Renderizar la surface del minimapa con el viewport actual (alineado a pixel)
float vx = std::floor(view_x_);
float vy = std::floor(view_y_);
SDL_FRect dst = {.x = vx, .y = vy,
.w = static_cast<float>(map_width_ + SHADOW_OFFSET), .h = static_cast<float>(map_height_ + SHADOW_OFFSET)};
SDL_FRect dst = {.x = vx, .y = vy, .w = static_cast<float>(map_width_ + SHADOW_OFFSET), .h = static_cast<float>(map_height_ + SHADOW_OFFSET)};
map_surface_->render(nullptr, &dst);
// Highlight de la room actual (solo si está completamente visible en el play area)