Compare commits
2 Commits
5f293cbddf
...
40766ad122
| Author | SHA1 | Date | |
|---|---|---|---|
| 40766ad122 | |||
| e67aeb10fe |
@@ -201,7 +201,7 @@ categories:
|
|||||||
DEBUG: [MODE, START]
|
DEBUG: [MODE, START]
|
||||||
DEBUG MODE: [ON, OFF]
|
DEBUG MODE: [ON, OFF]
|
||||||
DEBUG START: [HERE, ROOM, POS, SCENE]
|
DEBUG START: [HERE, ROOM, POS, SCENE]
|
||||||
DEBUG START SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, ENDING, ENDING2]
|
DEBUG START SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, DEMO, ENDING, ENDING2]
|
||||||
|
|
||||||
- keyword: ITEMS
|
- keyword: ITEMS
|
||||||
handler: cmd_items
|
handler: cmd_items
|
||||||
@@ -220,9 +220,9 @@ categories:
|
|||||||
- keyword: SCENE
|
- keyword: SCENE
|
||||||
handler: cmd_scene
|
handler: cmd_scene
|
||||||
description: Change scene
|
description: Change scene
|
||||||
usage: "SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]"
|
usage: "SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|DEMO|ENDING|ENDING2|RESTART]"
|
||||||
completions:
|
completions:
|
||||||
SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, ENDING, ENDING2, RESTART]
|
SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, DEMO, ENDING, ENDING2, RESTART]
|
||||||
|
|
||||||
- keyword: EDIT
|
- keyword: EDIT
|
||||||
handler: cmd_edit
|
handler: cmd_edit
|
||||||
|
|||||||
@@ -154,8 +154,9 @@ namespace GlobalInputs {
|
|||||||
// Detecta qué acción global ha sido presionada (si alguna)
|
// Detecta qué acción global ha sido presionada (si alguna)
|
||||||
auto getPressedAction() -> InputAction { // NOLINT(readability-function-cognitive-complexity)
|
auto getPressedAction() -> InputAction { // NOLINT(readability-function-cognitive-complexity)
|
||||||
// Qualsevol botó del comandament actua com a ACCEPT (saltar escenes
|
// Qualsevol botó del comandament actua com a ACCEPT (saltar escenes
|
||||||
// d'attract mode: logo, loading, credits, demo, ending...). Es prioritza
|
// d'attract mode: logo, loading, credits, demo, ending...). El botó
|
||||||
// sobre EXIT perquè s'envia com a flag d'event, no com a check d'acció.
|
// BACK queda filtrat prèviament a GlobalEvents per no colidir amb EXIT
|
||||||
|
// (excepte en emscripten, on BACK no pot sortir i sí pot saltar).
|
||||||
if (GlobalEvents::consumeGamepadButtonPressed()) {
|
if (GlobalEvents::consumeGamepadButtonPressed()) {
|
||||||
return InputAction::ACCEPT;
|
return InputAction::ACCEPT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,12 +390,21 @@ void Input::update() { // NOLINT(readability-convert-member-functions-to-static
|
|||||||
|
|
||||||
// --- MANDOS ---
|
// --- MANDOS ---
|
||||||
for (const auto& gamepad : gamepads_) {
|
for (const auto& gamepad : gamepads_) {
|
||||||
for (auto& binding : gamepad->bindings) {
|
for (auto& [action, state] : gamepad->bindings) {
|
||||||
bool button_is_down_now = static_cast<int>(SDL_GetGamepadButton(gamepad->pad, static_cast<SDL_GamepadButton>(binding.second.button))) != 0;
|
bool is_down_now = static_cast<int>(SDL_GetGamepadButton(gamepad->pad, static_cast<SDL_GamepadButton>(state.button))) != 0;
|
||||||
|
|
||||||
|
// JUMP accepta qualsevol dels 4 botons frontals (South/East/North/West)
|
||||||
|
if (action == Action::JUMP) {
|
||||||
|
is_down_now = is_down_now ||
|
||||||
|
(SDL_GetGamepadButton(gamepad->pad, SDL_GAMEPAD_BUTTON_SOUTH) != 0) ||
|
||||||
|
(SDL_GetGamepadButton(gamepad->pad, SDL_GAMEPAD_BUTTON_EAST) != 0) ||
|
||||||
|
(SDL_GetGamepadButton(gamepad->pad, SDL_GAMEPAD_BUTTON_NORTH) != 0) ||
|
||||||
|
(SDL_GetGamepadButton(gamepad->pad, SDL_GAMEPAD_BUTTON_WEST) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
// El estado .is_held del fotograma anterior nos sirve para saber si es un pulso nuevo
|
// El estado .is_held del fotograma anterior nos sirve para saber si es un pulso nuevo
|
||||||
binding.second.just_pressed = button_is_down_now && !binding.second.is_held;
|
state.just_pressed = is_down_now && !state.is_held;
|
||||||
binding.second.is_held = button_is_down_now;
|
state.is_held = is_down_now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,12 @@ class Input {
|
|||||||
// Movimiento del jugador
|
// Movimiento del jugador
|
||||||
{Action::LEFT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_LEFT)}},
|
{Action::LEFT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_LEFT)}},
|
||||||
{Action::RIGHT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_RIGHT)}},
|
{Action::RIGHT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_RIGHT)}},
|
||||||
{Action::JUMP, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_WEST)}}} {}
|
{Action::JUMP, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_WEST)}},
|
||||||
|
// Botó BACK del mando → sortir escena / tancar joc
|
||||||
|
{Action::EXIT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}},
|
||||||
|
{Action::CANCEL, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}},
|
||||||
|
// Botó START del mando → pausa
|
||||||
|
{Action::PAUSE, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_START)}}} {}
|
||||||
|
|
||||||
~Gamepad() {
|
~Gamepad() {
|
||||||
if (pad != nullptr) {
|
if (pad != nullptr) {
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ Director::Director() {
|
|||||||
// perquè la textura 256x192 no es vegi minúscula al canvas HTML,
|
// perquè la textura 256x192 no es vegi minúscula al canvas HTML,
|
||||||
// i desactivem el borde per aprofitar al màxim l'espai del canvas.
|
// i desactivem el borde per aprofitar al màxim l'espai del canvas.
|
||||||
Options::video.fullscreen = false;
|
Options::video.fullscreen = false;
|
||||||
|
Options::video.integer_scale = false;
|
||||||
Options::window.zoom = 4;
|
Options::window.zoom = 4;
|
||||||
Options::video.border.enabled = true;
|
Options::video.border.enabled = true;
|
||||||
Options::video.border.height = 8;
|
Options::video.border.height = 8;
|
||||||
|
|||||||
@@ -39,9 +39,18 @@ namespace GlobalEvents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marcar polsació de qualsevol botó del comandament (els consumirà GlobalInputs).
|
// Marcar polsació de qualsevol botó del comandament (els consumirà GlobalInputs
|
||||||
|
// per saltar escenes d'attract mode). El botó BACK queda exclòs perquè es
|
||||||
|
// reserva per a l'acció EXIT — excepte a emscripten, on no es pot sortir del
|
||||||
|
// joc i el BACK pot actuar com a botó genèric per saltar escenes.
|
||||||
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
|
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
gamepad_button_pressed_ = true;
|
gamepad_button_pressed_ = true;
|
||||||
|
#else
|
||||||
|
if (event.gbutton.button != SDL_GAMEPAD_BUTTON_BACK) {
|
||||||
|
gamepad_button_pressed_ = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enrutar eventos de texto a la consola cuando está activa
|
// Enrutar eventos de texto a la consola cuando está activa
|
||||||
|
|||||||
@@ -93,10 +93,16 @@ void Title::handleEvent(const SDL_Event& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Qualsevol botó del comandament al menú principal inicia partida directament
|
// Qualsevol botó del comandament al menú principal inicia partida directament
|
||||||
// (els bindings ja estan definits, no cal "pulsar 1" amb el teclat).
|
// (els bindings ja estan definits, no cal "pulsar 1" amb el teclat). El botó
|
||||||
|
// BACK queda exclòs perquè es reserva per a EXIT — excepte a emscripten, on
|
||||||
|
// no es pot sortir del joc i BACK pot actuar com a botó genèric d'inici.
|
||||||
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
|
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
|
||||||
state_ == State::MAIN_MENU &&
|
state_ == State::MAIN_MENU &&
|
||||||
!is_remapping_keyboard_ && !is_remapping_joystick_) {
|
!is_remapping_keyboard_ && !is_remapping_joystick_
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
&& event.gbutton.button != SDL_GAMEPAD_BUTTON_BACK
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
handleMainMenuKeyPress(SDLK_1); // PLAY
|
handleMainMenuKeyPress(SDLK_1); // PLAY
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,6 +491,9 @@ static auto cmdDebug(const std::vector<std::string>& args) -> std::string { //
|
|||||||
if (args[2] == "GAME") {
|
if (args[2] == "GAME") {
|
||||||
target = SceneManager::Scene::GAME;
|
target = SceneManager::Scene::GAME;
|
||||||
name = "game";
|
name = "game";
|
||||||
|
} else if (args[2] == "DEMO") {
|
||||||
|
target = SceneManager::Scene::DEMO;
|
||||||
|
name = "demo";
|
||||||
} else if (args[2] == "LOGO") {
|
} else if (args[2] == "LOGO") {
|
||||||
target = SceneManager::Scene::LOGO;
|
target = SceneManager::Scene::LOGO;
|
||||||
name = "logo";
|
name = "logo";
|
||||||
@@ -651,10 +654,10 @@ static auto cmdItems(const std::vector<std::string>& args) -> std::string {
|
|||||||
return "Items: " + std::to_string(count);
|
return "Items: " + std::to_string(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]
|
// SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|DEMO|ENDING|ENDING2|RESTART]
|
||||||
static auto cmdScene(const std::vector<std::string>& args) -> std::string {
|
static auto cmdScene(const std::vector<std::string>& args) -> std::string {
|
||||||
if (Options::kiosk.enabled) { return "Not allowed in kiosk mode"; }
|
if (Options::kiosk.enabled) { return "Not allowed in kiosk mode"; }
|
||||||
if (args.empty()) { return "usage: scene [logo|loading|title|credits|game|ending|ending2|restart]"; }
|
if (args.empty()) { return "usage: scene [logo|loading|title|credits|game|demo|ending|ending2|restart]"; }
|
||||||
|
|
||||||
if (args[0] == "RESTART") {
|
if (args[0] == "RESTART") {
|
||||||
SceneManager::scene_before_restart = SceneManager::current;
|
SceneManager::scene_before_restart = SceneManager::current;
|
||||||
@@ -677,6 +680,7 @@ static auto cmdScene(const std::vector<std::string>& args) -> std::string {
|
|||||||
if (args[0] == "TITLE") { return GO_TO(SceneManager::Scene::TITLE, "Title"); }
|
if (args[0] == "TITLE") { return GO_TO(SceneManager::Scene::TITLE, "Title"); }
|
||||||
if (args[0] == "CREDITS") { return GO_TO(SceneManager::Scene::CREDITS, "Credits"); }
|
if (args[0] == "CREDITS") { return GO_TO(SceneManager::Scene::CREDITS, "Credits"); }
|
||||||
if (args[0] == "GAME") { return GO_TO(SceneManager::Scene::GAME, "Game"); }
|
if (args[0] == "GAME") { return GO_TO(SceneManager::Scene::GAME, "Game"); }
|
||||||
|
if (args[0] == "DEMO") { return GO_TO(SceneManager::Scene::DEMO, "Demo"); }
|
||||||
if (args[0] == "ENDING") { return GO_TO(SceneManager::Scene::ENDING, "Ending"); }
|
if (args[0] == "ENDING") { return GO_TO(SceneManager::Scene::ENDING, "Ending"); }
|
||||||
if (args[0] == "ENDING2") { return GO_TO(SceneManager::Scene::ENDING2, "Ending 2"); }
|
if (args[0] == "ENDING2") { return GO_TO(SceneManager::Scene::ENDING2, "Ending 2"); }
|
||||||
return "Unknown scene: " + args[0];
|
return "Unknown scene: " + args[0];
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Notifier {
|
|||||||
Status state{Status::RISING};
|
Status state{Status::RISING};
|
||||||
Shape shape{Shape::SQUARED};
|
Shape shape{Shape::SQUARED};
|
||||||
SDL_FRect rect{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // rect.y es relativo a la base de la pila
|
SDL_FRect rect{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // rect.y es relativo a la base de la pila
|
||||||
int y{0}; // Top objetivo de la notificación relativo a la base de la pila
|
int y{0}; // Top objetivo de la notificación relativo a la base de la pila
|
||||||
int travel_dist{0};
|
int travel_dist{0};
|
||||||
std::string code;
|
std::string code;
|
||||||
bool can_be_removed{true};
|
bool can_be_removed{true};
|
||||||
@@ -97,8 +97,8 @@ class Notifier {
|
|||||||
static Notifier* notifier;
|
static Notifier* notifier;
|
||||||
|
|
||||||
// Métodos privados
|
// Métodos privados
|
||||||
void clearFinishedNotifications(); // Elimina las notificaciones finalizadas
|
void clearFinishedNotifications(); // Elimina las notificaciones finalizadas
|
||||||
void clearNotifications(); // Finaliza y elimina todas las notificaciones activas
|
void clearNotifications(); // Finaliza y elimina todas las notificaciones activas
|
||||||
[[nodiscard]] auto getStackBaseY() const -> int; // Y absoluta de la base de la pila (leída de Console)
|
[[nodiscard]] auto getStackBaseY() const -> int; // Y absoluta de la base de la pila (leída de Console)
|
||||||
|
|
||||||
// Constructor y destructor privados [SINGLETON]
|
// Constructor y destructor privados [SINGLETON]
|
||||||
|
|||||||
Reference in New Issue
Block a user