retocs sucosets al minimap
This commit is contained in:
@@ -17,13 +17,20 @@
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
|
||||
// Constructor: construye todo el minimapa
|
||||
MiniMap::MiniMap() {
|
||||
MiniMap::MiniMap(Uint8 bg_color, Uint8 conn_color) : bg_color_(bg_color), conn_color_(conn_color) {
|
||||
buildTileColorTable("standard.gif");
|
||||
layoutRooms();
|
||||
buildRoomSurfaces();
|
||||
composeFinalSurface();
|
||||
}
|
||||
|
||||
// Regenera la surface final con nuevo color de fondo
|
||||
void MiniMap::rebuild(Uint8 bg_color, Uint8 conn_color) {
|
||||
bg_color_ = bg_color;
|
||||
conn_color_ = conn_color;
|
||||
composeFinalSurface();
|
||||
}
|
||||
|
||||
// Analiza el tileset y crea tabla: tile_index → color predominante
|
||||
void MiniMap::buildTileColorTable(const std::string& tileset_name) {
|
||||
auto tileset = Resource::Cache::get()->getSurface(tileset_name);
|
||||
@@ -196,7 +203,7 @@ void MiniMap::composeFinalSurface() {
|
||||
Screen::get()->setRendererSurface(map_surface_);
|
||||
|
||||
// 1. Fondo general
|
||||
map_surface_->clear(COLOR_BACKGROUND);
|
||||
map_surface_->clear(bg_color_);
|
||||
|
||||
// 2. Líneas de conexión entre rooms (debajo de todo)
|
||||
drawConnections();
|
||||
@@ -240,22 +247,22 @@ void MiniMap::drawConnections() {
|
||||
int px = cellPixelX(mini.pos.x);
|
||||
int py = cellPixelY(mini.pos.y);
|
||||
|
||||
// Conexión derecha: línea horizontal desde el borde derecho de esta room hasta el borde izquierdo de la vecina
|
||||
// Conexión derecha
|
||||
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;
|
||||
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 = 1.0F};
|
||||
map_surface_->fillRect(&line, COLOR_CONNECTION);
|
||||
.w = static_cast<float>(GAP), .h = 3.0F};
|
||||
map_surface_->fillRect(&line, conn_color_);
|
||||
}
|
||||
|
||||
// Conexión abajo: línea vertical desde el borde inferior de esta room hasta el borde superior de la vecina
|
||||
// Conexión abajo
|
||||
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;
|
||||
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 = 1.0F, .h = static_cast<float>(GAP)};
|
||||
map_surface_->fillRect(&line, COLOR_CONNECTION);
|
||||
.w = 3.0F, .h = static_cast<float>(GAP)};
|
||||
map_surface_->fillRect(&line, conn_color_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,10 +274,6 @@ void MiniMap::render(const std::string& current_room) {
|
||||
auto game_surface = Screen::get()->getRendererSurface();
|
||||
if (!game_surface) { return; }
|
||||
|
||||
// Fondo negro en el play area
|
||||
SDL_FRect bg = {.x = 0, .y = 0, .w = static_cast<float>(PlayArea::WIDTH), .h = static_cast<float>(PlayArea::HEIGHT)};
|
||||
game_surface->fillRect(&bg, 0);
|
||||
|
||||
// Centrar el minimapa en el play area, centrado en la room actual
|
||||
auto it = room_positions_.find(current_room);
|
||||
if (it == room_positions_.end()) { return; }
|
||||
|
||||
Reference in New Issue
Block a user