From 95b82e5f628631444133f356558db6c45b9e6e0e Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 29 Oct 2025 11:56:34 +0100 Subject: [PATCH] fix: errors de renombrat de variables --- source/game/entities/player.cpp | 2 +- source/game/entities/player.hpp | 6 +++--- source/game/gameplay/room.cpp | 16 ++++++++-------- source/game/gameplay/scoreboard.cpp | 20 ++++++++++---------- source/game/scenes/game.cpp | 8 ++++---- source/utils/defines.hpp | 12 ++++++------ 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 2b9ad75..14cbc25 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -180,7 +180,7 @@ void Player::checkState(float delta_time) { void Player::switchBorders() { switch (border_) { case Room::Border::TOP: - y_ = PLAY_AREA_BOTTOM - HEIGHT - BLOCK; + y_ = PLAY_AREA_BOTTOM - HEIGHT - TILE_SIZE; setState(State::STANDING); break; diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index a4f91d1..cb0a6c3 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -82,9 +82,9 @@ class Player { private: // --- Constantes --- - static constexpr int WIDTH = 8; // Ancho del jugador - static constexpr int HEIGHT = 16; // ALto del jugador - static constexpr int MAX_FALLING_HEIGHT = BLOCK * 4; // Altura maxima permitida de caída en pixels + static constexpr int WIDTH = 8; // Ancho del jugador + static constexpr int HEIGHT = 16; // ALto del jugador + static constexpr int MAX_FALLING_HEIGHT = TILE_SIZE * 4; // Altura maxima permitida de caída en pixels // --- Constantes de física (per-second values) --- static constexpr float HORIZONTAL_VELOCITY = 40.0F; // Velocidad horizontal en pixels/segundo (0.6 * 66.67fps) diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index d033a4c..2856749 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -870,21 +870,21 @@ auto Room::setEnemy(Enemy::Data* enemy, const std::string& key, const std::strin } else if (key == "height") { enemy->h = std::stoi(value); } else if (key == "x") { - enemy->x = std::stof(value) * BLOCK; + enemy->x = std::stof(value) * TILE_SIZE; } else if (key == "y") { - enemy->y = std::stof(value) * BLOCK; + enemy->y = std::stof(value) * TILE_SIZE; } else if (key == "vx") { enemy->vx = std::stof(value); } else if (key == "vy") { enemy->vy = std::stof(value); } else if (key == "x1") { - enemy->x1 = std::stoi(value) * BLOCK; + enemy->x1 = std::stoi(value) * TILE_SIZE; } else if (key == "x2") { - enemy->x2 = std::stoi(value) * BLOCK; + enemy->x2 = std::stoi(value) * TILE_SIZE; } else if (key == "y1") { - enemy->y1 = std::stoi(value) * BLOCK; + enemy->y1 = std::stoi(value) * TILE_SIZE; } else if (key == "y2") { - enemy->y2 = std::stoi(value) * BLOCK; + enemy->y2 = std::stoi(value) * TILE_SIZE; } else if (key == "flip") { enemy->flip = stringToBool(value); } else if (key == "mirror") { @@ -917,9 +917,9 @@ auto Room::setItem(Item::Data* item, const std::string& key, const std::string& } else if (key == "counter") { item->counter = std::stoi(value); } else if (key == "x") { - item->x = std::stof(value) * BLOCK; + item->x = std::stof(value) * TILE_SIZE; } else if (key == "y") { - item->y = std::stof(value) * BLOCK; + item->y = std::stof(value) * TILE_SIZE; } else if (key == "tile") { item->tile = std::stof(value); } else if (key == "[/item]") { diff --git a/source/game/gameplay/scoreboard.cpp b/source/game/gameplay/scoreboard.cpp index 96b08f1..989725d 100644 --- a/source/game/gameplay/scoreboard.cpp +++ b/source/game/gameplay/scoreboard.cpp @@ -18,7 +18,7 @@ Scoreboard::Scoreboard(std::shared_ptr data) : item_surface_(Resource::get()->getSurface("items.gif")), data_(std::move(std::move(data))) { const float SURFACE_WIDTH = Options::game.width; - constexpr float SURFACE_HEIGHT = 6.0F * BLOCK; + constexpr float SURFACE_HEIGHT = 6.0F * TILE_SIZE; // Reserva memoria para los objetos auto player_texture = Resource::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif"); @@ -125,8 +125,8 @@ void Scoreboard::fillTexture() { surface_->clear(stringToColor("black")); // Anclas - constexpr int LINE1 = BLOCK; - constexpr int LINE2 = 3 * BLOCK; + constexpr int LINE1 = TILE_SIZE; + constexpr int LINE2 = 3 * TILE_SIZE; // Dibuja las vidas const int DESP = (counter_ / 40) % 8; @@ -143,21 +143,21 @@ void Scoreboard::fillTexture() { if (data_->music) { const Uint8 C = data_->color; SDL_FRect clip = {0, 8, 8, 8}; - item_surface_->renderWithColorReplace(20 * BLOCK, LINE2, 1, C, &clip); + item_surface_->renderWithColorReplace(20 * TILE_SIZE, LINE2, 1, C, &clip); } // Escribe los textos auto text = Resource::get()->getText("smb2"); const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10); const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10); - text->writeColored(BLOCK, LINE1, "Items collected ", data_->color); - text->writeColored(17 * BLOCK, LINE1, ITEMS_TEXT, items_color_); - text->writeColored(20 * BLOCK, LINE1, " Time ", data_->color); - text->writeColored(26 * BLOCK, LINE1, TIME_TEXT, stringToColor("white")); + text->writeColored(TILE_SIZE, LINE1, "Items collected ", data_->color); + text->writeColored(17 * TILE_SIZE, LINE1, ITEMS_TEXT, items_color_); + text->writeColored(20 * TILE_SIZE, LINE1, " Time ", data_->color); + text->writeColored(26 * TILE_SIZE, LINE1, TIME_TEXT, stringToColor("white")); 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(22 * BLOCK, LINE2, "Rooms", stringToColor("white")); - text->writeColored(28 * BLOCK, LINE2, ROOMS_TEXT, stringToColor("white")); + text->writeColored(22 * TILE_SIZE, LINE2, "Rooms", stringToColor("white")); + text->writeColored(28 * TILE_SIZE, LINE2, ROOMS_TEXT, stringToColor("white")); // Deja el renderizador como estaba Screen::get()->setRendererSurface(previuos_renderer); diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 96f2246..4ffd9b8 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -24,7 +24,7 @@ #include "game/options.hpp" // Para Options, options, Cheat, SectionState #include "game/scene_manager.hpp" // Para SceneManager #include "game/ui/notifier.hpp" // Para Notifier, NotificationText, CHEEVO_NO... -#include "utils/defines.hpp" // Para BLOCK, PLAY_AREA_HEIGHT, RoomBorder::BOTTOM +#include "utils/defines.hpp" // Para TILE_SIZE, PLAY_AREA_HEIGHT, RoomBorder::BOTTOM #include "utils/utils.hpp" // Para PaletteColor, stringToColor // Constructor @@ -36,10 +36,10 @@ Game::Game(Mode mode) mode_(mode), #ifdef _DEBUG current_room_("03.room"), - spawn_data_(Player::SpawnData(25 * BLOCK, 13 * BLOCK, 0, 0, 0, Player::State::STANDING, SDL_FLIP_HORIZONTAL)) + spawn_data_(Player::SpawnData(25 * TILE_SIZE, 13 * TILE_SIZE, 0, 0, 0, Player::State::STANDING, SDL_FLIP_HORIZONTAL)) #else current_room_("03.room"), - spawn_point_(PlayerSpawn(25 * BLOCK, 13 * BLOCK, 0, 0, 0, PlayerState::STANDING, SDL_FLIP_HORIZONTAL)) + spawn_data_(Player::SpawnData(25 * TILE_SIZE, 13 * TILE_SIZE, 0, 0, 0, Player::State::STANDING, SDL_FLIP_HORIZONTAL)) #endif { #ifdef _DEBUG @@ -192,7 +192,7 @@ void Game::renderDebugInfo() { auto surface = Screen::get()->getRendererSurface(); // Borra el marcador - SDL_FRect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT}; + SDL_FRect rect = {0, 18 * TILE_SIZE, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT}; surface->fillRect(&rect, static_cast(PaletteColor::BLACK)); // Pinta la rejilla diff --git a/source/utils/defines.hpp b/source/utils/defines.hpp index 106eec9..e4f53bc 100644 --- a/source/utils/defines.hpp +++ b/source/utils/defines.hpp @@ -15,18 +15,18 @@ constexpr const char* VERSION = "1.10"; constexpr Uint32 GAME_SPEED = 15; // Tamaño de bloque -constexpr int BLOCK = 8; -constexpr int HALF_BLOCK = 4; +constexpr int TILE_SIZE = 8; +constexpr int HALF_TILE = TILE_SIZE / 2; // Tamaño de la pantalla virtual constexpr int GAMECANVAS_WIDTH = 256; constexpr int GAMECANVAS_HEIGHT = 192; // Zona de juego -constexpr int PLAY_AREA_TOP = (0 * BLOCK); -constexpr int PLAY_AREA_BOTTOM = (16 * BLOCK); -constexpr int PLAY_AREA_LEFT = (0 * BLOCK); -constexpr int PLAY_AREA_RIGHT = (32 * BLOCK); +constexpr int PLAY_AREA_TOP = (0 * TILE_SIZE); +constexpr int PLAY_AREA_BOTTOM = (16 * TILE_SIZE); +constexpr int PLAY_AREA_LEFT = (0 * TILE_SIZE); +constexpr int PLAY_AREA_RIGHT = (32 * TILE_SIZE); constexpr int PLAY_AREA_WIDTH = PLAY_AREA_RIGHT - PLAY_AREA_LEFT; constexpr int PLAY_AREA_HEIGHT = PLAY_AREA_BOTTOM - PLAY_AREA_TOP; constexpr int PLAY_AREA_CENTER_X = PLAY_AREA_LEFT + (PLAY_AREA_WIDTH / 2);