granera con sarna no pica
This commit is contained in:
@@ -80,15 +80,6 @@ Game::Game(Mode mode)
|
||||
Console::get()->on_toggle = [this](bool open) { player_->setIgnoreInput(open); };
|
||||
if (Console::get()->isActive()) { player_->setIgnoreInput(true); }
|
||||
}
|
||||
GameControl::change_player_skin = [this](const std::string& skin_name) -> void {
|
||||
Options::game.player_skin = skin_name;
|
||||
player_->setSkin(skin_name);
|
||||
};
|
||||
GameControl::change_player_color = [this](int color) -> void {
|
||||
Options::game.player_color = color;
|
||||
player_->setColor();
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
GameControl::change_room = [this](const std::string& r) -> bool { return this->changeRoom(r); };
|
||||
GameControl::get_current_room = [this]() -> std::string { return current_room_; };
|
||||
@@ -108,7 +99,6 @@ Game::Game(Mode mode)
|
||||
} else {
|
||||
Options::cheats.invincible = invincible_before_debug_ ? Options::Cheat::State::ENABLED : Options::Cheat::State::DISABLED;
|
||||
}
|
||||
player_->setColor();
|
||||
scoreboard_data_->music = !Debug::get()->isEnabled();
|
||||
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||
};
|
||||
@@ -172,8 +162,6 @@ Game::~Game() {
|
||||
|
||||
ItemTracker::destroy();
|
||||
|
||||
GameControl::change_player_skin = nullptr;
|
||||
GameControl::change_player_color = nullptr;
|
||||
if (Console::get() != nullptr) { Console::get()->on_toggle = nullptr; }
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -646,12 +634,10 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
||||
|
||||
case SDLK_1:
|
||||
toggleCheat(Options::cheats.infinite_lives, Locale::get()->get("game.cheat_infinite_lives")); // NOLINT(readability-static-accessed-through-instance)
|
||||
player_->setColor();
|
||||
break;
|
||||
|
||||
case SDLK_2:
|
||||
toggleCheat(Options::cheats.invincible, Locale::get()->get("game.cheat_invincible")); // NOLINT(readability-static-accessed-through-instance)
|
||||
player_->setColor();
|
||||
break;
|
||||
|
||||
case SDLK_7:
|
||||
@@ -671,7 +657,6 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
||||
} else {
|
||||
Options::cheats.invincible = invincible_before_debug_ ? Options::Cheat::State::ENABLED : Options::Cheat::State::DISABLED;
|
||||
}
|
||||
player_->setColor();
|
||||
scoreboard_data_->music = !Debug::get()->isEnabled();
|
||||
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||
break;
|
||||
@@ -779,9 +764,6 @@ auto Game::changeRoom(const std::string& room_path) -> bool {
|
||||
// Pasa la nueva habitación al jugador
|
||||
player_->setRoom(room_);
|
||||
|
||||
// Recalcula el color del jugador (evita coincidir con el fondo)
|
||||
player_->setColor();
|
||||
|
||||
// Cambia la habitación actual
|
||||
current_room_ = room_path;
|
||||
|
||||
@@ -938,7 +920,7 @@ void Game::killPlayer() {
|
||||
}
|
||||
|
||||
// Sonido
|
||||
Audio::get()->playSound("death.wav", Audio::Group::GAME);
|
||||
Audio::get()->playSound(Defaults::Sound::Files::DEATH, Audio::Group::GAME);
|
||||
|
||||
// Transicionar al estado BLACK_SCREEN (el respawn ocurre en transitionToState)
|
||||
transitionToState(State::BLACK_SCREEN);
|
||||
@@ -956,7 +938,7 @@ void Game::togglePause() {
|
||||
// Inicializa al jugador
|
||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const bool IGNORE_INPUT = player_ != nullptr && player_->getIgnoreInput();
|
||||
std::string player_animations = Player::skinToAnimationPath(Options::game.player_skin);
|
||||
std::string player_animations = Player::skinToAnimationPath(Defaults::Game::Player::SKIN);
|
||||
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = player_animations, .room = std::move(room)};
|
||||
player_ = std::make_shared<Player>(PLAYER);
|
||||
if (IGNORE_INPUT) { player_->setIgnoreInput(true); }
|
||||
@@ -964,7 +946,7 @@ void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room
|
||||
|
||||
// Hace sonar la música
|
||||
void Game::keepMusicPlaying() {
|
||||
const std::string MUSIC_PATH = mode_ == Mode::GAME ? "574070_KUVO_Farewell_to_school.ogg" : "574071_EA_DTV.ogg";
|
||||
const std::string MUSIC_PATH = mode_ == Mode::GAME ? Defaults::Music::Files::GAME_TRACK : Defaults::Music::Files::TITLE_TRACK;
|
||||
|
||||
// Si la música no está sonando
|
||||
if (Audio::get()->getMusicState() == Audio::MusicState::STOPPED) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#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/defaults.hpp" // Para Defaults::Music::Files
|
||||
#include "game/options.hpp" // Para Options, options, SectionState, Section
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "game/ui/console.hpp" // Para Console
|
||||
@@ -41,8 +42,8 @@ Title::Title()
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
// Acciones iniciales
|
||||
Screen::get()->setBorderColor(0); // Cambia el color del borde
|
||||
Audio::get()->playMusic("574071_EA_DTV.ogg"); // Inicia la musica
|
||||
Screen::get()->setBorderColor(0); // Cambia el color del borde
|
||||
Audio::get()->playMusic(Defaults::Music::Files::TITLE_TRACK); // Inicia la musica
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -260,10 +261,6 @@ void Title::renderMainMenu() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
// Menú principal normal con 3 opciones centradas verticalmente en la zona
|
||||
const Uint8 COLOR = 8;
|
||||
const int TEXT_SIZE = menu_text_->getCharacterSize();
|
||||
@@ -394,9 +391,6 @@ void Title::applyKeyboardRemap() { // NOLINT(readability-convert-member-functio
|
||||
// Dibuja la pantalla de redefinir teclado
|
||||
void Title::renderKeyboardRemap() const {
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
const Uint8 COLOR = 8;
|
||||
const Uint8 ERROR_COLOR = 4;
|
||||
const int TEXT_SIZE = menu_text_->getCharacterSize();
|
||||
@@ -441,10 +435,6 @@ void Title::renderKeyboardRemap() const {
|
||||
|
||||
// Dibuja la pantalla de redefinir joystick
|
||||
void Title::renderJoystickRemap() const {
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
const Uint8 COLOR = 8;
|
||||
const Uint8 ERROR_COLOR = 4;
|
||||
const int TEXT_SIZE = menu_text_->getCharacterSize();
|
||||
@@ -502,23 +492,20 @@ void Title::handleJoystickRemap(const SDL_Event& event) {
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr Sint16 TRIGGER_THRESHOLD = 20000;
|
||||
constexpr Sint16 AXIS_THRESHOLD = 20000;
|
||||
|
||||
// Capturar triggers como botones (usando valores especiales 100/101)
|
||||
if (event.gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER && event.gaxis.value > TRIGGER_THRESHOLD) {
|
||||
if (event.gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER && event.gaxis.value > Defaults::Controls::JOYSTICK_AXIS_THRESHOLD) {
|
||||
captured_button = Input::TRIGGER_L2_AS_BUTTON; // 100
|
||||
axis_cooldown_ = 0.5F; // Cooldown de medio segundo
|
||||
} else if (event.gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER && event.gaxis.value > TRIGGER_THRESHOLD) {
|
||||
} else if (event.gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER && event.gaxis.value > Defaults::Controls::JOYSTICK_AXIS_THRESHOLD) {
|
||||
captured_button = Input::TRIGGER_R2_AS_BUTTON; // 101
|
||||
axis_cooldown_ = 0.5F;
|
||||
}
|
||||
// Capturar ejes del stick analógico (usando valores especiales 200+)
|
||||
else if (event.gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX) {
|
||||
if (event.gaxis.value < -AXIS_THRESHOLD) {
|
||||
if (event.gaxis.value < -Defaults::Controls::JOYSTICK_AXIS_THRESHOLD) {
|
||||
captured_button = 200; // Left stick izquierda
|
||||
axis_cooldown_ = 0.5F;
|
||||
} else if (event.gaxis.value > AXIS_THRESHOLD) {
|
||||
} else if (event.gaxis.value > Defaults::Controls::JOYSTICK_AXIS_THRESHOLD) {
|
||||
captured_button = 201; // Left stick derecha
|
||||
axis_cooldown_ = 0.5F;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ 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
|
||||
|
||||
// --- Constantes de layout del menú ---
|
||||
static constexpr int MENU_ZONE_Y = 73; // Coordenada Y de la zona de menú
|
||||
static constexpr int MENU_ZONE_HEIGHT = 102; // Alto de la zona de menú
|
||||
// --- Métodos ---
|
||||
void handleEvents(); // Comprueba el manejador de eventos
|
||||
void handleMainMenuKeyPress(SDL_Keycode key); // Maneja las teclas del menu principal
|
||||
|
||||
Reference in New Issue
Block a user