Options: afegida opció per invertir el y_axis (la recre te els mandos mal cablejats)

This commit is contained in:
2025-06-26 22:26:38 +02:00
parent c923f0d310
commit ed91bff7df
4 changed files with 21 additions and 6 deletions

View File

@@ -160,8 +160,8 @@ void Director::loadScoreFile()
void Director::bindInputs() void Director::bindInputs()
{ {
// Teclado - Movimiento del jugador // Teclado - Movimiento del jugador
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP); Input::get()->bindKey(InputAction::UP, Options::settings.is_y_axis_inverted ? SDL_SCANCODE_DOWN : SDL_SCANCODE_UP);
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN); Input::get()->bindKey(InputAction::DOWN, Options::settings.is_y_axis_inverted ? SDL_SCANCODE_UP : SDL_SCANCODE_DOWN);
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT); Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT);
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT); Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT);
@@ -202,8 +202,8 @@ void Director::bindInputs()
for (int i = 0; i < NUM_GAMEPADS; ++i) for (int i = 0; i < NUM_GAMEPADS; ++i)
{ {
// Mando - Movimiento del jugador // Mando - Movimiento del jugador
Input::get()->bindGameControllerButton(i, InputAction::UP, SDL_GAMEPAD_BUTTON_DPAD_UP); Input::get()->bindGameControllerButton(i, InputAction::UP, Options::settings.is_y_axis_inverted ? SDL_GAMEPAD_BUTTON_DPAD_DOWN : SDL_GAMEPAD_BUTTON_DPAD_UP);
Input::get()->bindGameControllerButton(i, InputAction::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN); Input::get()->bindGameControllerButton(i, InputAction::DOWN, Options::settings.is_y_axis_inverted ? SDL_GAMEPAD_BUTTON_DPAD_UP : SDL_GAMEPAD_BUTTON_DPAD_DOWN);
Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT); Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT); Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);

View File

@@ -55,6 +55,7 @@ namespace Options
settings.language = Lang::Code::VALENCIAN; settings.language = Lang::Code::VALENCIAN;
settings.autofire = true; settings.autofire = true;
settings.shutdown_enabled = false; settings.shutdown_enabled = false;
settings.is_y_axis_inverted = false;
settings.clearLastHiScoreEntries(); settings.clearLastHiScoreEntries();
settings.config_file = Asset::get()->get("config.txt"); settings.config_file = Asset::get()->get("config.txt");
@@ -172,6 +173,7 @@ namespace Options
file << "game.difficulty=" << static_cast<int>(settings.difficulty) << "\n"; file << "game.difficulty=" << static_cast<int>(settings.difficulty) << "\n";
file << "game.autofire=" << boolToString(settings.autofire) << "\n"; file << "game.autofire=" << boolToString(settings.autofire) << "\n";
file << "game.shutdown_enabled=" << boolToString(settings.shutdown_enabled) << "\n"; file << "game.shutdown_enabled=" << boolToString(settings.shutdown_enabled) << "\n";
file << "game.is_y_axis_inverted=" << boolToString(settings.is_y_axis_inverted) << "\n";
// Opciones de mandos // Opciones de mandos
file << "\n\n## CONTROLLERS\n"; file << "\n\n## CONTROLLERS\n";
@@ -276,6 +278,10 @@ namespace Options
{ {
settings.shutdown_enabled = stringToBool(value); settings.shutdown_enabled = stringToBool(value);
} }
else if (var == "game.is_y_axis_inverted")
{
settings.is_y_axis_inverted = stringToBool(value);
}
// Opciones de mandos // Opciones de mandos
else if (var == "controller.0.name") else if (var == "controller.0.name")

View File

@@ -81,6 +81,7 @@ namespace Options
Lang::Code language; // Idioma usado en el juego Lang::Code language; // Idioma usado en el juego
bool autofire; // Indicador de autofire bool autofire; // Indicador de autofire
bool shutdown_enabled; // Especifica si se puede apagar el sistema bool shutdown_enabled; // Especifica si se puede apagar el sistema
bool is_y_axis_inverted; // Indica si hay que invertir el eje Y de los controles
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla
std::string config_file; // Ruta al fichero donde guardar la configuracion y las opciones del juego std::string config_file; // Ruta al fichero donde guardar la configuracion y las opciones del juego

View File

@@ -30,7 +30,15 @@ void initParam()
precalculateZones(); precalculateZones();
// SCOREBOARD // SCOREBOARD
param.scoreboard = {0, 216, param.game.width, 40}; param.scoreboard.rect = {0, 216, param.game.width, 40};
param.scoreboard.separator_autocolor = false;
param.scoreboard.separator_color = Color();
param.scoreboard.easy_color = Color();
param.scoreboard.normal_color = Color();
param.scoreboard.hard_color = Color();
param.scoreboard.text_autocolor = false;
param.scoreboard.text_color1 = Color();
param.scoreboard.text_color2 = Color();
// FADE // FADE
param.fade.num_squares_width = param.game.width / 2; param.fade.num_squares_width = param.game.width / 2;