llevat soport per a colors amb nom
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE, Map::WIDTH, Map::HEIGHT
|
||||
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
|
||||
|
||||
/**
|
||||
@@ -83,9 +84,9 @@ class CollisionMap {
|
||||
|
||||
private:
|
||||
// --- Constantes ---
|
||||
static constexpr int TILE_SIZE = 8; // Tamaño del tile en pixels
|
||||
static constexpr int MAP_WIDTH = 32; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = 16; // Alto del mapa en tiles
|
||||
static constexpr int TILE_SIZE = ::Tile::SIZE; // Tamaño del tile en pixels
|
||||
static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles
|
||||
|
||||
// --- Datos de la habitación ---
|
||||
std::vector<int> tile_map_; // Índices de tiles de la habitación
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data
|
||||
#include "game/gameplay/tilemap_renderer.hpp" // Para TilemapRenderer
|
||||
#include "utils/defines.hpp" // Para TILE_SIZE
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Constructor
|
||||
Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
||||
@@ -35,7 +35,7 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
||||
tilemap_renderer_ = std::make_unique<TilemapRenderer>(tile_map_, tile_set_width_, surface_, bg_color_, conveyor_belt_direction_);
|
||||
tilemap_renderer_->initialize(collision_map_.get()); // Inicializa (crea map_surface, pinta tiles, busca animados)
|
||||
|
||||
Screen::get()->setBorderColor(stringToColor(border_color_)); // Establece el color del borde
|
||||
Screen::get()->setBorderColor(border_color_); // Establece el color del borde
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -46,8 +46,8 @@ void Room::initializeRoom(const Data& room) {
|
||||
number_ = room.number;
|
||||
bg_color_ = room.bg_color;
|
||||
border_color_ = room.border_color;
|
||||
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
|
||||
item_color2_ = room.item_color2.empty() ? "magenta" : room.item_color2;
|
||||
item_color1_ = room.item_color1;
|
||||
item_color2_ = room.item_color2;
|
||||
upper_room_ = room.upper_room;
|
||||
lower_room_ = room.lower_room;
|
||||
left_room_ = room.left_room;
|
||||
@@ -71,8 +71,8 @@ void Room::initializeRoom(const Data& room) {
|
||||
if (!ItemTracker::get()->hasBeenPicked(room.number, ITEM_POS)) {
|
||||
// Crear una copia local de los datos del item
|
||||
Item::Data item_copy = item;
|
||||
item_copy.color1 = stringToColor(item_color1_);
|
||||
item_copy.color2 = stringToColor(item_color2_);
|
||||
item_copy.color1 = item_color1_;
|
||||
item_copy.color2 = item_color2_;
|
||||
|
||||
// Crear el objeto Item usando la copia modificada
|
||||
item_manager_->addItem(std::make_shared<Item>(item_copy));
|
||||
@@ -142,21 +142,19 @@ void Room::setTile(int index, int tile_value) {
|
||||
}
|
||||
|
||||
// Cambia color de fondo y redibuja el mapa (para editor)
|
||||
void Room::setBgColor(const std::string& color) {
|
||||
void Room::setBgColor(Uint8 color) {
|
||||
bg_color_ = color;
|
||||
tilemap_renderer_->setBgColor(color);
|
||||
tilemap_renderer_->redrawMap(collision_map_.get());
|
||||
}
|
||||
|
||||
// Cambia colores de items en vivo (para editor)
|
||||
void Room::setItemColors(const std::string& color1, const std::string& color2) {
|
||||
void Room::setItemColors(Uint8 color1, Uint8 color2) {
|
||||
item_color1_ = color1;
|
||||
item_color2_ = color2;
|
||||
Uint8 c1 = stringToColor(color1);
|
||||
Uint8 c2 = stringToColor(color2);
|
||||
auto* item_mgr = item_manager_.get();
|
||||
for (int i = 0; i < item_mgr->getCount(); ++i) {
|
||||
item_mgr->getItem(i)->setColors(c1, c2);
|
||||
item_mgr->getItem(i)->setColors(color1, color2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "game/entities/enemy.hpp" // Para EnemyData
|
||||
#include "game/entities/item.hpp" // Para ItemData
|
||||
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE, Map::WIDTH, Map::HEIGHT
|
||||
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
|
||||
class Sprite; // lines 12-12
|
||||
class Surface; // lines 13-13
|
||||
@@ -40,10 +41,10 @@ class Room {
|
||||
|
||||
struct Data {
|
||||
std::string number; // Numero de la habitación
|
||||
std::string bg_color; // Color de fondo de la habitación
|
||||
std::string border_color; // Color del borde de la pantalla
|
||||
std::string item_color1; // Color 1 para los items de la habitación
|
||||
std::string item_color2; // Color 2 para los items de la habitación
|
||||
Uint8 bg_color{0}; // Color de fondo de la habitación
|
||||
Uint8 border_color{0}; // Color del borde de la pantalla
|
||||
Uint8 item_color1{12}; // Color 1 para los items de la habitación
|
||||
Uint8 item_color2{6}; // Color 2 para los items de la habitación
|
||||
std::string upper_room; // Identificador de la habitación que se encuentra arriba
|
||||
std::string lower_room; // Identificador de la habitación que se encuentra abajo
|
||||
std::string left_room; // Identificador de la habitación que se encuentra a la izquierda
|
||||
@@ -61,8 +62,8 @@ class Room {
|
||||
|
||||
// --- Funciones ---
|
||||
[[nodiscard]] auto getNumber() const -> const std::string& { return number_; } // Devuelve el numero de la habitación
|
||||
[[nodiscard]] auto getBGColor() const -> Uint8 { return stringToColor(bg_color_); } // Devuelve el color de la habitación
|
||||
[[nodiscard]] auto getBorderColor() const -> Uint8 { return stringToColor(border_color_); } // Devuelve el color del borde
|
||||
[[nodiscard]] auto getBGColor() const -> Uint8 { return bg_color_; } // Devuelve el color de la habitación
|
||||
[[nodiscard]] auto getBorderColor() const -> Uint8 { return border_color_; } // Devuelve el color del borde
|
||||
void renderMap(); // Dibuja el mapa en pantalla
|
||||
void renderEnemies(); // Dibuja los enemigos en pantalla
|
||||
void renderItems(); // Dibuja los objetos en pantalla
|
||||
@@ -72,8 +73,8 @@ class Room {
|
||||
void resetEnemyPositions(const std::vector<Enemy::Data>& enemy_data); // Resetea enemigos a posiciones iniciales
|
||||
auto getEnemyManager() -> EnemyManager* { return enemy_manager_.get(); } // Acceso al gestor de enemigos (para editor)
|
||||
auto getItemManager() -> ItemManager* { return item_manager_.get(); } // Acceso al gestor de items (para editor)
|
||||
void setBgColor(const std::string& color); // Cambia color de fondo y redibuja (para editor)
|
||||
void setItemColors(const std::string& color1, const std::string& color2); // Cambia colores de items (para editor)
|
||||
void setBgColor(Uint8 color); // Cambia color de fondo y redibuja (para editor)
|
||||
void setItemColors(Uint8 color1, Uint8 color2); // Cambia colores de items (para editor)
|
||||
void setTile(int index, int tile_value); // Cambia un tile y redibuja (para editor)
|
||||
[[nodiscard]] auto getTileSetFile() const -> const std::string& { return tile_set_file_; }
|
||||
[[nodiscard]] auto getTileSetWidth() const -> int { return tile_set_width_; }
|
||||
@@ -106,9 +107,9 @@ class Room {
|
||||
|
||||
private:
|
||||
// Constantes
|
||||
static constexpr int TILE_SIZE = 8; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = 32; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = 16; // Alto del mapa en tiles
|
||||
static constexpr int TILE_SIZE = ::Tile::SIZE; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles
|
||||
|
||||
// Objetos y punteros
|
||||
std::unique_ptr<EnemyManager> enemy_manager_; // Gestor de enemigos de la habitación
|
||||
@@ -120,10 +121,10 @@ class Room {
|
||||
|
||||
// --- Variables ---
|
||||
std::string number_; // Numero de la habitación
|
||||
std::string bg_color_; // Color de fondo de la habitación
|
||||
std::string border_color_; // Color del borde de la pantalla
|
||||
std::string item_color1_; // Color 1 para los items de la habitación
|
||||
std::string item_color2_; // Color 2 para los items de la habitación
|
||||
Uint8 bg_color_{0}; // Color de fondo de la habitación
|
||||
Uint8 border_color_{0}; // Color del borde de la pantalla
|
||||
Uint8 item_color1_{12}; // Color 1 para los items de la habitación
|
||||
Uint8 item_color2_{6}; // Color 2 para los items de la habitación
|
||||
std::string upper_room_; // Identificador de la habitación que se encuentra arriba
|
||||
std::string lower_room_; // Identificador de la habitación que se encuentra abajp
|
||||
std::string left_room_; // Identificador de la habitación que se encuentra a la izquierda
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "core/resources/resource_helper.hpp" // Para Resource::Helper
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Convierte room connection de YAML a formato interno
|
||||
auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
||||
@@ -20,11 +20,11 @@ auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string
|
||||
return value + ".yaml";
|
||||
}
|
||||
|
||||
// Lee un nodo de color tolerando tanto string ("red", "bright_blue") como entero (índice de paleta)
|
||||
static auto readColorNode(const fkyaml::node& node) -> std::string {
|
||||
if (node.is_string()) { return node.get_value<std::string>(); }
|
||||
if (node.is_integer()) { return std::to_string(node.get_value<int>()); }
|
||||
return "black";
|
||||
// Lee un nodo de color como Uint8 (acepta entero directo o string numérico)
|
||||
static auto readColorNode(const fkyaml::node& node) -> Uint8 {
|
||||
if (node.is_integer()) { return static_cast<Uint8>(node.get_value<int>()); }
|
||||
if (node.is_string()) { return static_cast<Uint8>(safeStoi(node.get_value<std::string>(), 0)); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Convierte string de autoSurface a int
|
||||
@@ -47,7 +47,7 @@ auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int { // NOLIN
|
||||
// Convierte un tilemap 2D a vector 1D flat
|
||||
auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int> { // NOLINT(readability-convert-member-functions-to-static, readability-named-parameter)
|
||||
std::vector<int> tilemap_flat;
|
||||
tilemap_flat.reserve(512); // 16 rows × 32 cols
|
||||
tilemap_flat.reserve(Map::WIDTH * Map::HEIGHT);
|
||||
|
||||
for (const auto& row : tilemap_2d) {
|
||||
for (int tile : row) {
|
||||
@@ -86,13 +86,13 @@ void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, con
|
||||
}
|
||||
|
||||
// Item colors
|
||||
room.item_color1 = room_node.contains("itemColor1")
|
||||
? readColorNode(room_node["itemColor1"])
|
||||
: "yellow";
|
||||
if (room_node.contains("itemColor1")) {
|
||||
room.item_color1 = readColorNode(room_node["itemColor1"]);
|
||||
}
|
||||
|
||||
room.item_color2 = room_node.contains("itemColor2")
|
||||
? readColorNode(room_node["itemColor2"])
|
||||
: "magenta";
|
||||
if (room_node.contains("itemColor2")) {
|
||||
room.item_color2 = readColorNode(room_node["itemColor2"]);
|
||||
}
|
||||
|
||||
// Dirección de la cinta transportadora (left/none/right)
|
||||
room.conveyor_belt_direction = room_node.contains("conveyorBelt")
|
||||
@@ -130,11 +130,11 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const
|
||||
|
||||
// Read 2D array
|
||||
std::vector<std::vector<int>> tilemap_2d;
|
||||
tilemap_2d.reserve(16);
|
||||
tilemap_2d.reserve(Map::HEIGHT);
|
||||
|
||||
for (const auto& row_node : tilemap_node) {
|
||||
std::vector<int> row;
|
||||
row.reserve(32);
|
||||
row.reserve(Map::WIDTH);
|
||||
|
||||
for (const auto& tile_node : row_node) {
|
||||
row.push_back(tile_node.get_value<int>());
|
||||
@@ -225,9 +225,9 @@ auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
||||
}
|
||||
|
||||
// Color
|
||||
enemy.color = enemy_node.contains("color")
|
||||
? enemy_node["color"].get_value_or<std::string>("white")
|
||||
: "white";
|
||||
if (enemy_node.contains("color")) {
|
||||
enemy.color = readColorNode(enemy_node["color"]);
|
||||
}
|
||||
|
||||
// Optional fields
|
||||
enemy.flip = enemy_node.contains("flip")
|
||||
@@ -293,8 +293,8 @@ auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data&
|
||||
: 0;
|
||||
|
||||
// Colors (assigned from room defaults)
|
||||
item.color1 = stringToColor(room.item_color1);
|
||||
item.color2 = stringToColor(room.item_color2);
|
||||
item.color1 = room.item_color1;
|
||||
item.color2 = room.item_color2;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "game/entities/player.hpp" // Para Player::skinToAnimationPath
|
||||
#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame
|
||||
#include "utils/defines.hpp" // Para BLOCK
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Constructor
|
||||
Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
||||
@@ -32,13 +32,10 @@ Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
||||
surface_dest_ = {.x = 0, .y = Options::game.height - SURFACE_HEIGHT, .w = SURFACE_WIDTH, .h = SURFACE_HEIGHT};
|
||||
|
||||
// Inicializa el color de items
|
||||
items_color_ = stringToColor("white");
|
||||
items_color_ = 14;
|
||||
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<std::string> COLORS = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
||||
for (const auto& color : COLORS) {
|
||||
color_.push_back(stringToColor(color));
|
||||
}
|
||||
color_ = {2, 6, 8, 10, 12, 14, 3, 7, 9, 11, 13, 15};
|
||||
}
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
@@ -118,9 +115,9 @@ void Scoreboard::updateItemsColor(float delta_time) {
|
||||
|
||||
// Alternar color cada ITEMS_COLOR_BLINK_DURATION
|
||||
if (items_color_timer_ < ITEMS_COLOR_BLINK_DURATION) {
|
||||
items_color_ = stringToColor("white");
|
||||
items_color_ = 14;
|
||||
} else {
|
||||
items_color_ = stringToColor("magenta");
|
||||
items_color_ = 6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +133,7 @@ void Scoreboard::fillTexture() {
|
||||
Screen::get()->setRendererSurface(surface_);
|
||||
|
||||
// Limpia la textura
|
||||
surface_->clear(stringToColor("black"));
|
||||
surface_->clear(0);
|
||||
|
||||
// Dibuja las vidas
|
||||
const int WALK_FRAMES = player_sprite_->getCurrentAnimationSize();
|
||||
@@ -164,11 +161,11 @@ void Scoreboard::fillTexture() {
|
||||
text->writeColored(ITEMS_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.items"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(ITEMS_VALUE_X, LINE1_Y, ITEMS_TEXT, items_color_);
|
||||
text->writeColored(TIME_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.time"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(TIME_VALUE_X, LINE1_Y, TIME_TEXT, stringToColor("white"));
|
||||
text->writeColored(TIME_VALUE_X, LINE1_Y, TIME_TEXT, 14);
|
||||
|
||||
const std::string ROOMS_TEXT = std::to_string(data_->rooms / 100) + std::to_string((data_->rooms % 100) / 10) + std::to_string(data_->rooms % 10);
|
||||
text->writeColored(ROOMS_LABEL_X, LINE2_Y, Locale::get()->get("scoreboard.rooms"), stringToColor("white")); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(ROOMS_VALUE_X, LINE2_Y, ROOMS_TEXT, stringToColor("white"));
|
||||
text->writeColored(ROOMS_LABEL_X, LINE2_Y, Locale::get()->get("scoreboard.rooms"), 14); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(ROOMS_VALUE_X, LINE2_Y, ROOMS_TEXT, 14);
|
||||
|
||||
// Indicadores de trucos activos (fuente 8bithud)
|
||||
auto cheat_text = Resource::Cache::get()->getText("8bithud");
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Constructor
|
||||
TilemapRenderer::TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, std::string bg_color, int conveyor_belt_direction)
|
||||
TilemapRenderer::TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, Uint8 bg_color, int conveyor_belt_direction)
|
||||
: tile_map_(std::move(tile_map)),
|
||||
tile_set_width_(tile_set_width),
|
||||
tileset_surface_(std::move(tileset_surface)),
|
||||
bg_color_(std::move(bg_color)),
|
||||
bg_color_(bg_color),
|
||||
conveyor_belt_direction_(conveyor_belt_direction) {
|
||||
// Crear la surface del mapa
|
||||
map_surface_ = std::make_shared<Surface>(PlayArea::WIDTH, PlayArea::HEIGHT);
|
||||
@@ -62,37 +62,37 @@ static void renderDebugCollisionSurfaces(const CollisionMap* collision_map) {
|
||||
|
||||
// BottomSurfaces
|
||||
for (auto l : collision_map->getBottomFloors()) {
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, 2);
|
||||
}
|
||||
|
||||
// TopSurfaces
|
||||
for (auto l : collision_map->getTopFloors()) {
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, 4);
|
||||
}
|
||||
|
||||
// LeftSurfaces
|
||||
for (auto l : collision_map->getLeftWalls()) {
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, 8);
|
||||
}
|
||||
|
||||
// RightSurfaces
|
||||
for (auto l : collision_map->getRightWalls()) {
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, 6);
|
||||
}
|
||||
|
||||
// LeftSlopes
|
||||
for (auto l : collision_map->getLeftSlopes()) {
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, 10);
|
||||
}
|
||||
|
||||
// RightSlopes
|
||||
for (auto l : collision_map->getRightSlopes()) {
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, 12);
|
||||
}
|
||||
|
||||
// AutoSurfaces (Conveyor Belts)
|
||||
for (auto l : collision_map->getConveyorBeltFloors()) {
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, 14);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void TilemapRenderer::setTile(int index, int tile_value) {
|
||||
|
||||
// Borrar la celda con el color de fondo
|
||||
SDL_FRect cell = {.x = static_cast<float>(col * TILE_SIZE), .y = static_cast<float>(row * TILE_SIZE), .w = static_cast<float>(TILE_SIZE), .h = static_cast<float>(TILE_SIZE)};
|
||||
map_surface_->fillRect(&cell, stringToColor(bg_color_));
|
||||
map_surface_->fillRect(&cell, bg_color_);
|
||||
|
||||
// Dibujar el nuevo tile (si no es vacío ni animado)
|
||||
if (tile_value > -1) {
|
||||
@@ -135,10 +135,9 @@ void TilemapRenderer::setTile(int index, int tile_value) {
|
||||
|
||||
// Pinta el mapa estático y debug lines
|
||||
void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const Uint8 COLOR = stringToColor(bg_color_);
|
||||
auto previous_renderer = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(map_surface_);
|
||||
map_surface_->clear(COLOR);
|
||||
map_surface_->clear(bg_color_);
|
||||
|
||||
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class TilemapRenderer {
|
||||
* @param bg_color Color de fondo de la habitación (como string)
|
||||
* @param conveyor_belt_direction Dirección de las cintas transportadoras (-1, 0, +1)
|
||||
*/
|
||||
TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, std::string bg_color, int conveyor_belt_direction);
|
||||
TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, Uint8 bg_color, int conveyor_belt_direction);
|
||||
~TilemapRenderer() = default;
|
||||
|
||||
// Prohibir copia y movimiento
|
||||
@@ -69,7 +69,7 @@ class TilemapRenderer {
|
||||
* Llamado cuando se activa/desactiva el modo debug para actualizar la visualización
|
||||
*/
|
||||
void redrawMap(const CollisionMap* collision_map);
|
||||
void setBgColor(const std::string& color) { bg_color_ = color; }
|
||||
void setBgColor(Uint8 color) { bg_color_ = color; }
|
||||
void setTile(int index, int tile_value); // Cambia un tile y repinta esa celda
|
||||
#endif
|
||||
|
||||
@@ -92,9 +92,9 @@ class TilemapRenderer {
|
||||
};
|
||||
|
||||
// === Constantes ===
|
||||
static constexpr int TILE_SIZE = Tile::SIZE; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = PlayArea::WIDTH / Tile::SIZE; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = PlayArea::HEIGHT / Tile::SIZE; // Alto del mapa en tiles
|
||||
static constexpr int TILE_SIZE = Tile::SIZE; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = Map::WIDTH; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = Map::HEIGHT; // Alto del mapa en tiles
|
||||
static constexpr int PLAY_AREA_WIDTH = PlayArea::WIDTH; // Ancho del área de juego en pixels
|
||||
static constexpr int PLAY_AREA_HEIGHT = PlayArea::HEIGHT; // Alto del área de juego en pixels
|
||||
static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame (3 frames @ 60fps)
|
||||
@@ -103,7 +103,7 @@ class TilemapRenderer {
|
||||
std::vector<int> tile_map_; // Índices de tiles de la habitación
|
||||
int tile_set_width_; // Ancho del tileset en tiles
|
||||
std::shared_ptr<Surface> tileset_surface_; // Gráficos del tileset
|
||||
std::string bg_color_; // Color de fondo
|
||||
Uint8 bg_color_{0}; // Color de fondo
|
||||
int conveyor_belt_direction_; // Dirección de conveyor belts
|
||||
|
||||
// === Renderizado ===
|
||||
|
||||
Reference in New Issue
Block a user