eliminades referencies antigues

This commit is contained in:
2026-04-07 10:06:42 +02:00
parent 158affe1f9
commit 39170a086e
13 changed files with 28 additions and 1302 deletions

View File

@@ -60,7 +60,6 @@ namespace Defaults::Sound {
namespace Defaults::Cheat {
constexpr bool INFINITE_LIVES = false; // Vidas infinitas desactivadas por defecto
constexpr bool INVINCIBLE = false; // Invencibilidad desactivada por defecto
constexpr bool JAIL_IS_OPEN = false; // Jail abierta desactivada por defecto
} // namespace Defaults::Cheat
namespace Defaults::Stats {
@@ -88,13 +87,8 @@ namespace Defaults::Localization {
constexpr const char* LANGUAGE = "ca"; // Idioma por defecto (en = inglés, ca = catalán)
} // namespace Defaults::Localization
namespace Defaults::Game::Items {
constexpr const float PERCENT_TO_OPEN_THE_JAIL = 0.9F; // Porcentaje de items necesarios para abrir la jail
} // namespace Defaults::Game::Items
namespace Defaults::Game::Room {
constexpr const char* INITIAL = "03.yaml"; // Habitación de inicio
constexpr const char* END_ROOM = "01"; // Habitación final (jail)
} // namespace Defaults::Game::Room
namespace Defaults::Game::Player {

View File

@@ -45,19 +45,6 @@ Cheevos::~Cheevos() {
// Inicializa los logros
void Cheevos::init() { // NOLINT(readability-convert-member-functions-to-static)
cheevos_list_.clear();
auto* loc = Locale::get();
cheevos_list_.emplace_back(Achievement{.id = 1, .caption = loc->get("achievements.c1"), .description = loc->get("achievements.d1"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 2, .caption = loc->get("achievements.c2"), .description = loc->get("achievements.d2"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 3, .caption = loc->get("achievements.c3"), .description = loc->get("achievements.d3"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 4, .caption = loc->get("achievements.c4"), .description = loc->get("achievements.d4"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 5, .caption = loc->get("achievements.c5"), .description = loc->get("achievements.d5"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 6, .caption = loc->get("achievements.c6"), .description = loc->get("achievements.d6"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 7, .caption = loc->get("achievements.c7"), .description = loc->get("achievements.d7"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 8, .caption = loc->get("achievements.c8"), .description = loc->get("achievements.d8"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 9, .caption = loc->get("achievements.c9"), .description = loc->get("achievements.d9"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 10, .caption = loc->get("achievements.c10"), .description = loc->get("achievements.d10"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 11, .caption = loc->get("achievements.c11"), .description = loc->get("achievements.d11"), .icon = 2});
cheevos_list_.emplace_back(Achievement{.id = 12, .caption = loc->get("achievements.c12"), .description = loc->get("achievements.d12"), .icon = 2});
}
// Busca un logro por id y devuelve el indice

View File

@@ -31,7 +31,6 @@ void Scoreboard::render() {
// Actualiza las variables del objeto
void Scoreboard::update(float delta_time) {
updateItemsColor(delta_time);
fillTexture();
if (!is_paused_) {
@@ -64,17 +63,6 @@ void Scoreboard::setPaused(bool value) {
}
}
// Actualiza el color de la cantidad de items recogidos
void Scoreboard::updateItemsColor(float delta_time) {
if (!data_->jail_is_open) { return; }
items_color_timer_ += delta_time;
if (items_color_timer_ >= ITEMS_COLOR_BLINK_DURATION * 2.0F) {
items_color_timer_ = 0.0F;
}
items_color_ = (items_color_timer_ < ITEMS_COLOR_BLINK_DURATION) ? VALUE_COLOR : 6;
}
// Devuelve la cantidad de minutos de juego transcurridos
auto Scoreboard::getMinutes() -> int {
return getTime().minutes;
@@ -114,7 +102,7 @@ void Scoreboard::fillTexture() {
x += text->length(SEP);
text->writeColored(x, LINE1_Y, ITEMS_LABEL, LABEL_COLOR);
x += text->length(ITEMS_LABEL);
text->writeColoredMono(x, LINE1_Y, ITEMS_STR, items_color_, MONO_W);
text->writeColoredMono(x, LINE1_Y, ITEMS_STR, VALUE_COLOR, MONO_W);
x += text->lengthMono(ITEMS_STR, MONO_W);
text->writeColored(x, LINE1_Y, SEP, LABEL_COLOR);
x += text->length(SEP);

View File

@@ -18,7 +18,6 @@ class Scoreboard {
bool music{true}; // Indica si ha de sonar la música durante el juego
Uint8 color{0}; // Color para escribir el texto del marcador
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
bool jail_is_open{false}; // Indica si se puede entrar a la Jail
};
// Métodos públicos
@@ -39,8 +38,6 @@ class Scoreboard {
};
// Constantes de tiempo
static constexpr float ITEMS_COLOR_BLINK_DURATION = 0.333F;
// Posición de los elementos (2 líneas centradas verticalmente en surface de 24px)
static constexpr int LINE1_Y = 5;
static constexpr int LINE2_Y = 13;
@@ -51,7 +48,6 @@ class Scoreboard {
// Métodos privados
auto getTime() -> ClockData;
void updateItemsColor(float delta_time);
void fillTexture();
// Objetos y punteros
@@ -63,7 +59,5 @@ class Scoreboard {
Uint32 paused_time_{0};
Uint32 paused_time_elapsed_{0};
ClockData clock_{};
Uint8 items_color_{VALUE_COLOR};
SDL_FRect surface_dest_{};
float items_color_timer_{0.0F};
};

View File

@@ -39,11 +39,10 @@ namespace Options {
State infinite_lives{Defaults::Cheat::INFINITE_LIVES ? State::ENABLED : State::DISABLED}; // Indica si el jugador dispone de vidas infinitas
State invincible{Defaults::Cheat::INVINCIBLE ? State::ENABLED : State::DISABLED}; // Indica si el jugador puede morir
State jail_is_open{Defaults::Cheat::JAIL_IS_OPEN ? State::ENABLED : State::DISABLED}; // Indica si la Jail está abierta
// Método para comprobar si alguno de los tres primeros trucos está activo
// Método para comprobar si algún truco está activo
[[nodiscard]] auto enabled() const -> bool {
return infinite_lives == State::ENABLED || invincible == State::ENABLED || jail_is_open == State::ENABLED;
return infinite_lives == State::ENABLED || invincible == State::ENABLED;
}
};

View File

@@ -19,7 +19,6 @@
#include "core/system/global_events.hpp" // Para check
#include "game/defaults.hpp" // Para Defaults::Game
#include "game/game_control.hpp" // Para GameControl
#include "game/gameplay/cheevos.hpp" // Para Cheevos
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
#include "game/gameplay/room.hpp" // Para Room, RoomData
#include "game/gameplay/room_tracker.hpp" // Para RoomTracker
@@ -39,7 +38,7 @@
// Constructor
Game::Game(Mode mode)
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks(), Options::cheats.jail_is_open == Options::Cheat::State::ENABLED)),
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks())),
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
room_tracker_(std::make_shared<RoomTracker>()),
mode_(mode),
@@ -69,13 +68,9 @@ Game::Game(Mode mode)
demoInit();
room_ = std::make_shared<Room>(current_room_, scoreboard_data_);
initPlayer(spawn_data_, room_);
total_items_ = getTotalItems();
game_backbuffer_surface_ = std::make_shared<Surface>(Options::game.width, Options::game.height);
changeRoom(current_room_);
Cheevos::get()->enable(!Options::cheats.enabled()); // Deshabilita los logros si hay trucos activados
Cheevos::get()->clearUnobtainableState();
#ifdef _DEBUG
Console::get()->setScope("debug");
@@ -335,8 +330,7 @@ void Game::updatePlaying(float delta_time) {
checkPlayerAndItems();
checkPlayerAndEnemies();
checkIfPlayerIsAlive();
checkEndGame();
checkSomeCheevos();
// Avanzar transición
if (transitioning_) {
@@ -884,9 +878,6 @@ void Game::killPlayer() {
--scoreboard_data_->lives;
}
// Invalida el logro de pasarse el juego sin morir
Cheevos::get()->setUnobtainable(11);
// Sonido
Audio::get()->playSound("death.wav", Audio::Group::GAME);
@@ -906,41 +897,6 @@ void Game::setScoreBoardColor() { // NOLINT(readability-convert-member-function
scoreboard_data_->color = IS_BLACK || IS_BRIGHT_BLACK ? 14 : BORDER_COLOR;
}
// Comprueba si ha finalizado el juego
auto Game::checkEndGame() -> bool {
const bool IS_ON_THE_ROOM = room_->getNumber() == Defaults::Game::Room::END_ROOM; // Estar en la habitación que toca
const bool HAVE_THE_ITEMS =
scoreboard_data_->items >= int(total_items_ * Defaults::Game::Items::PERCENT_TO_OPEN_THE_JAIL) ||
Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
scoreboard_data_->jail_is_open = HAVE_THE_ITEMS;
if (HAVE_THE_ITEMS && IS_ON_THE_ROOM && IS_ON_THE_DOOR) {
// Comprueba los logros de completar el juego
checkEndGameCheevos();
// Iniciar transición de fade en vez de cambio inmediato de escena
transitionToState(State::FADE_TO_ENDING);
Audio::get()->fadeOutMusic(1000); // Fade out de música en 1 segundo
return true;
}
return false;
}
// Obtiene la cantidad total de items que hay en el mapeado del juego
auto Game::getTotalItems() -> int {
int items = 0;
auto rooms = Resource::Cache::get()->getRooms();
for (const auto& room : rooms) {
items += room.room->items.size();
}
return items;
}
// Pone el juego en pausa
void Game::togglePause() {
paused_ = !paused_;
@@ -950,63 +906,6 @@ void Game::togglePause() {
scoreboard_->setPaused(paused_);
}
// Comprueba algunos logros
void Game::checkSomeCheevos() { // NOLINT(readability-convert-member-functions-to-static)
auto* cheevos = Cheevos::get();
// Logros sobre la cantidad de items
if (scoreboard_data_->items == total_items_) {
cheevos->unlock(4);
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.75F) {
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.5F) {
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.25F) {
cheevos->unlock(1);
}
// Logros sobre las habitaciones visitadas
if (scoreboard_data_->rooms >= 60) {
cheevos->unlock(7);
cheevos->unlock(6);
cheevos->unlock(5);
} else if (scoreboard_data_->rooms >= 40) {
cheevos->unlock(6);
cheevos->unlock(5);
} else if (scoreboard_data_->rooms >= 20) {
cheevos->unlock(5);
}
}
// Comprueba los logros de completar el juego
void Game::checkEndGameCheevos() { // NOLINT(readability-convert-member-functions-to-static)
auto* cheevos = Cheevos::get();
// "Complete the game"
cheevos->unlock(8);
// "Complete the game without entering the jail"
cheevos->unlock(9);
// "Complete the game with all items"
if (scoreboard_data_->items == total_items_) {
cheevos->unlock(10);
}
// "Complete the game without dying"
cheevos->unlock(11);
// "Complete the game in under 30 minutes"
if (scoreboard_->getMinutes() < 30) {
cheevos->unlock(12);
}
}
// Inicializa al jugador
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)

View File

@@ -75,11 +75,7 @@ class Game {
void checkIfPlayerIsAlive(); // Comprueba si el jugador esta vivo
void killPlayer(); // Mata al jugador
void setScoreBoardColor(); // Pone el color del marcador en función del color del borde de la habitación
auto checkEndGame() -> bool; // Comprueba si ha finalizado el juego
static auto getTotalItems() -> int; // Obtiene la cantidad total de items que hay en el mapeado del juego
void togglePause(); // Pone el juego en pausa
void checkSomeCheevos(); // Comprueba algunos logros
void checkEndGameCheevos(); // Comprueba los logros de completar el juego
void initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room); // Inicializa al jugador
void endTransition(); // Finaliza la transición entre pantallas
void keepMusicPlaying(); // Hace sonar la música
@@ -106,7 +102,6 @@ class Game {
DeltaTimer delta_timer_; // Timer para calcular delta time
std::string current_room_; // Fichero de la habitación actual
Player::SpawnData spawn_data_; // Lugar de la habitación donde aparece el jugador
int total_items_; // Cantidad total de items que hay en el mapeado del juego
bool paused_{false}; // Indica si el juego se encuentra en pausa
float state_time_{0.0F}; // Tiempo acumulado en el estado actual
float fade_accumulator_{0.0F}; // Acumulador de tiempo para el fade

View File

@@ -16,7 +16,6 @@
#include "core/resources/resource_list.hpp" // Para Asset
#include "core/system/event_buffer.hpp" // Para EventBuffer
#include "core/system/global_events.hpp" // Para check
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement
#include "game/options.hpp" // Para Options, options, SectionState, Section
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/ui/console.hpp" // Para Console
@@ -42,7 +41,6 @@ Title::Title()
SceneManager::options = SceneManager::Options::NONE;
// Acciones iniciales
createCheevosTexture(); // Crea y rellena la textura para mostrar los logros
Screen::get()->setBorderColor(0); // Cambia el color del borde
Audio::get()->playMusic("574071_EA_DTV.ogg"); // Inicia la musica
}
@@ -111,11 +109,6 @@ void Title::handleMainMenuKeyPress(SDL_Keycode key) {
// Si no hay gamepad, simplemente no hacer nada
break;
case SDLK_4:
// PROJECTS
transitionToState(State::CHEEVOS_MENU);
break;
default:
break;
}
@@ -139,19 +132,6 @@ void Title::handleInput(float delta_time) {
return;
}
switch (state_) {
case State::CHEEVOS_MENU:
if (Input::get()->checkAction(InputAction::ACCEPT, Input::DO_NOT_ALLOW_REPEAT) ||
Input::get()->checkAction(InputAction::CANCEL, Input::DO_NOT_ALLOW_REPEAT)) {
resetCheevosScroll();
transitionToState(State::MAIN_MENU);
}
break;
default:
break;
}
GlobalInputs::handle();
}
@@ -175,10 +155,6 @@ void Title::updateState(float delta_time) {
updateMainMenu(delta_time);
break;
case State::CHEEVOS_MENU:
updateCheevosMenu(delta_time);
break;
case State::FADE_MENU:
updateFadeMenu(delta_time);
break;
@@ -231,49 +207,6 @@ void Title::updateMainMenu(float delta_time) {
}
}
// Actualiza el estado CHEEVOS_MENU
void Title::updateCheevosMenu(float delta_time) {
// Determina la velocidad objetivo basada en el input
float target_velocity = 0.0F;
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
target_velocity = CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia abajo
} else if (Input::get()->checkAction(InputAction::LEFT, Input::ALLOW_REPEAT)) {
target_velocity = -CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia arriba
}
// Interpola suavemente la velocidad actual hacia la velocidad objetivo
if (target_velocity != 0.0F) {
// Acelerando hacia la velocidad objetivo
const float ACCELERATION_STEP = CHEEVOS_SCROLL_ACCELERATION * delta_time;
if (cheevos_scroll_velocity_ < target_velocity) {
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + ACCELERATION_STEP, target_velocity);
} else if (cheevos_scroll_velocity_ > target_velocity) {
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - ACCELERATION_STEP, target_velocity);
}
} else {
// Desacelerando hacia 0
const float DECELERATION_STEP = CHEEVOS_SCROLL_DECELERATION * delta_time;
if (cheevos_scroll_velocity_ > 0.0F) {
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - DECELERATION_STEP, 0.0F);
} else if (cheevos_scroll_velocity_ < 0.0F) {
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + DECELERATION_STEP, 0.0F);
}
}
// Aplica la velocidad actual al scroll position
if (cheevos_scroll_velocity_ != 0.0F) {
cheevos_surface_view_.y += cheevos_scroll_velocity_ * delta_time;
// Ajusta los límites
const float BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0.0F, BOTTOM);
cheevos_sprite_->setClip(cheevos_surface_view_);
}
// No incrementar state_time_ (no timeout en este estado)
}
// Actualiza el estado FADE_MENU
void Title::updateFadeMenu(float delta_time) {
fade_accumulator_ += delta_time;
@@ -310,68 +243,6 @@ void Title::render() {
Screen::get()->render();
}
// Crea y rellena la textura para mostrar los logros
void Title::createCheevosTexture() { // NOLINT(readability-convert-member-functions-to-static)
// Define la zona central del menu (entre el logo y la marquesina)
constexpr int MENU_ZONE_Y = 73; // Top of menu zone
constexpr int MENU_ZONE_HEIGHT = 102; // Height of menu zone
// Crea la textura con el listado de logros
const auto CHEEVOS_LIST = Cheevos::get()->list();
const auto TEXT = Resource::Cache::get()->getText("subatomic");
constexpr int CHEEVOS_TEXTURE_WIDTH = 200;
constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = MENU_ZONE_HEIGHT;
constexpr int CHEEVOS_PADDING = 10;
const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (TEXT->getCharacterSize() * 2) + 1;
const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * CHEEVOS_LIST.size()) + 2 + TEXT->getCharacterSize() + 8;
cheevos_surface_ = std::make_shared<Surface>(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT);
// Prepara para dibujar sobre la textura
auto previuos_renderer = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(cheevos_surface_);
// Rellena la textura con color sólido
const auto CHEEVOS_BG_COLOR = 0;
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
// Escribe la lista de logros en la textura
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects"); // NOLINT(readability-static-accessed-through-instance)
const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->getTotalUnlockedAchievements()) + " / " + std::to_string(Cheevos::get()->size()) + ")";
int pos = 2;
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, 9);
pos += TEXT->getCharacterSize();
const Uint8 CHEEVO_LOCKED_COLOR = 14;
const Uint8 CHEEVO_UNLOCKED_COLOR = 9;
constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
for (const auto& cheevo : CHEEVOS_LIST) {
const Uint8 CHEEVO_COLOR = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR;
pos += CHEEVOS_PADDING;
constexpr int HALF = CHEEVOS_PADDING / 2;
cheevos_surface_->drawLine(LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, CHEEVO_COLOR);
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, CHEEVO_COLOR);
pos += TEXT->getCharacterSize() + 1;
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, CHEEVO_COLOR);
pos += TEXT->getCharacterSize();
}
// Restablece el RenderSurface
Screen::get()->setRendererSurface(previuos_renderer);
// Crea el sprite para el listado de logros (usa la zona del menu)
cheevos_sprite_ = std::make_unique<Sprite>(cheevos_surface_, (GameCanvas::WIDTH - cheevos_surface_->getWidth()) / 2, MENU_ZONE_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
cheevos_surface_view_ = {.x = 0, .y = 0, .w = cheevos_surface_->getWidth(), .h = CHEEVOS_TEXTURE_VIEW_HEIGHT};
cheevos_sprite_->setClip(cheevos_surface_view_);
}
// Resetea el scroll de la lista de logros
void Title::resetCheevosScroll() {
cheevos_surface_view_.y = 0;
cheevos_scroll_velocity_ = 0.0F;
cheevos_sprite_->setClip(cheevos_surface_view_);
}
// Dibuja el logo con el titulo del juego
void Title::renderGameLogo() {
game_logo_sprite_->render();
@@ -389,30 +260,24 @@ void Title::renderMainMenu() {
return;
}
// Zona central del menu (debe coincidir con la textura de cheevos)
// Zona central del menu
constexpr int MENU_ZONE_Y = 73;
constexpr int MENU_ZONE_HEIGHT = 102;
// Menú principal normal con 4 opciones centradas verticalmente en la zona
// Menú principal normal con 3 opciones centradas verticalmente en la zona
const Uint8 COLOR = 8;
const int TEXT_SIZE = menu_text_->getCharacterSize();
const int MENU_CENTER_Y = MENU_ZONE_Y + (MENU_ZONE_HEIGHT / 2);
const int SPACING = 2 * TEXT_SIZE; // Espaciado entre opciones
// Calcula posiciones centradas verticalmente (4 items con espaciado)
const int TOTAL_HEIGHT = 3 * SPACING; // 3 espacios entre 4 items
// Calcula posiciones centradas verticalmente (3 items con espaciado)
const int TOTAL_HEIGHT = 2 * SPACING; // 2 espacios entre 3 items
const int START_Y = MENU_CENTER_Y - (TOTAL_HEIGHT / 2);
auto* loc = Locale::get();
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y, loc->get("title.menu.play"), 1, COLOR);
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + SPACING, loc->get("title.menu.keyboard"), 1, COLOR);
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + (2 * SPACING), loc->get("title.menu.joystick"), 1, COLOR);
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + (3 * SPACING), loc->get("title.menu.projects"), 1, COLOR);
}
// Dibuja el menu de logros
void Title::renderCheevosMenu() {
cheevos_sprite_->render();
}
// Dibuja los elementos en la surface
@@ -432,12 +297,6 @@ void Title::fillTitleSurface() {
break;
case State::CHEEVOS_MENU:
renderGameLogo();
renderCheevosMenu();
break;
default:
break;
}
@@ -534,7 +393,7 @@ void Title::applyKeyboardRemap() { // NOLINT(readability-convert-member-functio
// Dibuja la pantalla de redefinir teclado
void Title::renderKeyboardRemap() const {
// Zona central del menu (debe coincidir con la textura de cheevos)
// Zona central del menu
constexpr int MENU_ZONE_Y = 73;
constexpr int MENU_ZONE_HEIGHT = 102;
@@ -582,7 +441,7 @@ void Title::renderKeyboardRemap() const {
// Dibuja la pantalla de redefinir joystick
void Title::renderJoystickRemap() const {
// Zona central del menu (debe coincidir con la textura de cheevos)
// Zona central del menu
constexpr int MENU_ZONE_Y = 73;
constexpr int MENU_ZONE_HEIGHT = 102;

View File

@@ -26,7 +26,6 @@ class Title {
// --- Estructuras y enumeraciones ---
enum class State {
MAIN_MENU,
CHEEVOS_MENU,
FADE_MENU,
POST_FADE_MENU,
};
@@ -35,10 +34,6 @@ class Title {
static constexpr float FADE_STEP_INTERVAL = 0.05F; // Intervalo entre pasos de fade (antes cada 4 frames)
static constexpr float POST_FADE_DELAY = 1.0F; // Delay después del fade (pantalla en negro)
static constexpr float KEYBOARD_REMAP_DISPLAY_DELAY = 2.0F; // Tiempo mostrando teclas definidas antes de guardar
static constexpr float CHEEVOS_SCROLL_MAX_SPEED = 180.0F; // Velocidad máxima de scroll de logros (pixels/segundo)
static constexpr float CHEEVOS_SCROLL_ACCELERATION = 600.0F; // Aceleración del scroll (pixels/segundo²)
static constexpr float CHEEVOS_SCROLL_DECELERATION = 800.0F; // Desaceleración del scroll (pixels/segundo²)
// --- Métodos ---
void handleEvents(); // Comprueba el manejador de eventos
void handleMainMenuKeyPress(SDL_Keycode key); // Maneja las teclas del menu principal
@@ -46,12 +41,10 @@ class Title {
void updateState(float delta_time); // Actualiza el estado actual
void transitionToState(State new_state); // Transiciona a un nuevo estado
void updateMainMenu(float delta_time); // Actualiza MAIN_MENU
void updateCheevosMenu(float delta_time); // Actualiza CHEEVOS_MENU
void updateFadeMenu(float delta_time); // Actualiza FADE_MENU
void updatePostFadeMenu(float delta_time); // Actualiza POST_FADE_MENU
void renderGameLogo(); // Dibuja el logo con el titulo del juego
void renderMainMenu(); // Dibuja el menu principal
void renderCheevosMenu(); // Dibuja el menu de logros
void renderKeyboardRemap() const; // Dibuja la pantalla de redefinir teclado
void renderJoystickRemap() const; // Dibuja la pantalla de redefinir joystick
void handleKeyboardRemap(const SDL_Event& event); // Maneja la captura de teclas
@@ -63,24 +56,16 @@ class Title {
void applyJoystickRemap(); // Aplica y guarda los botones del gamepad redefinidos
static auto getActionName(int step) -> std::string; // Retorna el nombre de la accion (LEFT/RIGHT/JUMP)
static auto getButtonName(int button) -> std::string; // Retorna el nombre amigable del boton del gamepad
void createCheevosTexture(); // Crea y rellena la surface para mostrar los logros
void resetCheevosScroll(); // Resetea el scroll de la lista de logros
void fillTitleSurface(); // Dibuja los elementos en la surface
// --- Variables miembro ---
// Objetos y punteros
std::shared_ptr<Surface> game_logo_surface_; // Textura con los graficos
std::unique_ptr<Sprite> game_logo_sprite_; // SSprite para manejar la surface
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
std::unique_ptr<Sprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
std::shared_ptr<Surface> title_surface_; // Surface donde se dibuja toda la clase
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
std::shared_ptr<Text> menu_text_; // Texto para los menus
// Variables de estado del menú de logros
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
float cheevos_scroll_velocity_{0.0F}; // Velocidad actual del scroll de logros (pixels/segundo)
// Variables de estado general
State state_; // Estado en el que se encuentra el bucle principal
float state_time_{0.0F}; // Tiempo acumulado en el estado actual

View File

@@ -794,11 +794,7 @@ static auto cmdShow(const std::vector<std::string>& args) -> std::string {
Notifier::get()->show({"NOTIFICATION"});
return "Notification shown";
}
if (!args.empty() && args[0] == "CHEEVO") {
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c1")}, Notifier::Style::CHEEVO, -1, false); // NOLINT(readability-static-accessed-through-instance)
return "Cheevo notification shown";
}
if (args.empty() || args[0] != "INFO") { return "usage: show [info|notification|cheevo]"; }
if (args.empty() || args[0] != "INFO") { return "usage: show [info|notification]"; }
#else
if (args.empty() || args[0] != "INFO") { return "usage: show [info]"; }
#endif
@@ -818,7 +814,7 @@ static auto cmdHide(const std::vector<std::string>& args) -> std::string {
// CHEAT [subcomando]
static auto cmdCheat(const std::vector<std::string>& args) -> std::string { // NOLINT(readability-function-cognitive-complexity)
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
if (args.empty()) { return "usage: cheat [infinite lives|invincibility|open the jail|close the jail]"; }
if (args.empty()) { return "usage: cheat [infinite lives|invincibility]"; }
// CHEAT INFINITE LIVES [ON|OFF]
if (args[0] == "INFINITE") {
@@ -858,23 +854,7 @@ static auto cmdCheat(const std::vector<std::string>& args) -> std::string { //
return std::string("Invincibility ") + (cheat == State::ENABLED ? "ON" : "OFF");
}
// CHEAT OPEN THE JAIL
if (args[0] == "OPEN") {
if (args.size() < 3 || args[1] != "THE" || args[2] != "JAIL") { return "usage: cheat open the jail"; }
if (Options::cheats.jail_is_open == Options::Cheat::State::ENABLED) { return "Jail already open"; }
Options::cheats.jail_is_open = Options::Cheat::State::ENABLED;
return "Jail opened";
}
// CHEAT CLOSE THE JAIL
if (args[0] == "CLOSE") {
if (args.size() < 3 || args[1] != "THE" || args[2] != "JAIL") { return "usage: cheat close the jail"; }
if (Options::cheats.jail_is_open == Options::Cheat::State::DISABLED) { return "Jail already closed"; }
Options::cheats.jail_is_open = Options::Cheat::State::DISABLED;
return "Jail closed";
}
return "usage: cheat [infinite lives|invincibility|open the jail|close the jail]";
return "usage: cheat [infinite lives|invincibility]";
}
// PLAYER SKIN / PLAYER COLOR