la consola ja no pausa al jugador
This commit is contained in:
@@ -55,6 +55,7 @@ void Player::update(float delta_time) {
|
|||||||
|
|
||||||
// Comprueba las entradas y modifica variables
|
// Comprueba las entradas y modifica variables
|
||||||
void Player::handleInput() {
|
void Player::handleInput() {
|
||||||
|
if (ignore_input_) { return; }
|
||||||
if (Input::get()->checkAction(InputAction::LEFT)) {
|
if (Input::get()->checkAction(InputAction::LEFT)) {
|
||||||
wanna_go_ = Direction::LEFT;
|
wanna_go_ = Direction::LEFT;
|
||||||
} else if (Input::get()->checkAction(InputAction::RIGHT)) {
|
} else if (Input::get()->checkAction(InputAction::RIGHT)) {
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class Player {
|
|||||||
//[[nodiscard]] auto isAlive() const -> bool { return is_alive_ || (Options::cheats.invincible == Options::Cheat::State::ENABLED); } // Comprueba si el jugador esta vivo
|
//[[nodiscard]] auto isAlive() const -> bool { return is_alive_ || (Options::cheats.invincible == Options::Cheat::State::ENABLED); } // Comprueba si el jugador esta vivo
|
||||||
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; } // Comprueba si el jugador esta vivo
|
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; } // Comprueba si el jugador esta vivo
|
||||||
void setPaused(bool value) { is_paused_ = value; } // Pone el jugador en modo pausa
|
void setPaused(bool value) { is_paused_ = value; } // Pone el jugador en modo pausa
|
||||||
|
void setIgnoreInput(bool value) { ignore_input_ = value; } // Ignora inputs del jugador (física sigue activa)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// --- Funciones de debug ---
|
// --- Funciones de debug ---
|
||||||
@@ -146,6 +147,7 @@ class Player {
|
|||||||
// --- Variables de juego ---
|
// --- Variables de juego ---
|
||||||
bool is_alive_ = true; // Indica si el jugador esta vivo o no
|
bool is_alive_ = true; // Indica si el jugador esta vivo o no
|
||||||
bool is_paused_ = false; // Indica si el jugador esta en modo pausa
|
bool is_paused_ = false; // Indica si el jugador esta en modo pausa
|
||||||
|
bool ignore_input_ = false; // Ignora inputs pero mantiene la física activa
|
||||||
bool auto_movement_ = false; // Indica si esta siendo arrastrado por una superficie automatica
|
bool auto_movement_ = false; // Indica si esta siendo arrastrado por una superficie automatica
|
||||||
Room::Border border_ = Room::Border::TOP; // Indica en cual de los cuatro bordes se encuentra
|
Room::Border border_ = Room::Border::TOP; // Indica en cual de los cuatro bordes se encuentra
|
||||||
int last_grounded_position_ = 0; // Ultima posición en Y en la que se estaba en contacto con el suelo (hace doble función: tracking de caída + altura inicial del salto)
|
int last_grounded_position_ = 0; // Ultima posición en Y en la que se estaba en contacto con el suelo (hace doble función: tracking de caída + altura inicial del salto)
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ Game::Game(Mode mode)
|
|||||||
Cheevos::get()->clearUnobtainableState();
|
Cheevos::get()->clearUnobtainableState();
|
||||||
|
|
||||||
GameControl::refresh_player_color = [this]() -> void { player_->setColor(); };
|
GameControl::refresh_player_color = [this]() -> void { player_->setColor(); };
|
||||||
|
Console::get()->on_toggle = [this](bool open) { player_->setIgnoreInput(open); };
|
||||||
GameControl::change_player_skin = [this](int skin_num) -> void {
|
GameControl::change_player_skin = [this](int skin_num) -> void {
|
||||||
Options::game.player_skin = skin_num;
|
Options::game.player_skin = skin_num;
|
||||||
player_->setSkin(skin_num);
|
player_->setSkin(skin_num);
|
||||||
@@ -116,6 +117,7 @@ Game::~Game() {
|
|||||||
|
|
||||||
GameControl::refresh_player_color = nullptr;
|
GameControl::refresh_player_color = nullptr;
|
||||||
GameControl::change_player_skin = nullptr;
|
GameControl::change_player_skin = nullptr;
|
||||||
|
Console::get()->on_toggle = nullptr;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
GameControl::change_room = nullptr;
|
GameControl::change_room = nullptr;
|
||||||
@@ -229,7 +231,6 @@ void Game::updatePlaying(float delta_time) {
|
|||||||
room_->update(delta_time);
|
room_->update(delta_time);
|
||||||
switch (mode_) {
|
switch (mode_) {
|
||||||
case Mode::GAME:
|
case Mode::GAME:
|
||||||
if (!Console::get()->isActive()) {
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Maneja el arrastre del jugador con el ratón (debug)
|
// Maneja el arrastre del jugador con el ratón (debug)
|
||||||
handleDebugMouseDrag(delta_time);
|
handleDebugMouseDrag(delta_time);
|
||||||
@@ -241,7 +242,6 @@ void Game::updatePlaying(float delta_time) {
|
|||||||
#else
|
#else
|
||||||
player_->update(delta_time);
|
player_->update(delta_time);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
checkPlayerIsOnBorder();
|
checkPlayerIsOnBorder();
|
||||||
checkPlayerAndItems();
|
checkPlayerAndItems();
|
||||||
checkPlayerAndEnemies();
|
checkPlayerAndEnemies();
|
||||||
|
|||||||
@@ -907,6 +907,7 @@ void Console::toggle() {
|
|||||||
cursor_visible_ = true;
|
cursor_visible_ = true;
|
||||||
SDL_StartTextInput(SDL_GetKeyboardFocus());
|
SDL_StartTextInput(SDL_GetKeyboardFocus());
|
||||||
if (Notifier::get() != nullptr) { Notifier::get()->addYOffset(static_cast<int>(height_)); }
|
if (Notifier::get() != nullptr) { Notifier::get()->addYOffset(static_cast<int>(height_)); }
|
||||||
|
if (on_toggle) { on_toggle(true); }
|
||||||
break;
|
break;
|
||||||
case Status::ACTIVE:
|
case Status::ACTIVE:
|
||||||
status_ = Status::VANISHING;
|
status_ = Status::VANISHING;
|
||||||
@@ -915,6 +916,7 @@ void Console::toggle() {
|
|||||||
saved_input_.clear();
|
saved_input_.clear();
|
||||||
SDL_StopTextInput(SDL_GetKeyboardFocus());
|
SDL_StopTextInput(SDL_GetKeyboardFocus());
|
||||||
if (Notifier::get() != nullptr) { Notifier::get()->removeYOffset(static_cast<int>(height_)); }
|
if (Notifier::get() != nullptr) { Notifier::get()->removeYOffset(static_cast<int>(height_)); }
|
||||||
|
if (on_toggle) { on_toggle(false); }
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Durante RISING o VANISHING no se hace nada
|
// Durante RISING o VANISHING no se hace nada
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#include <deque> // Para deque (historial)
|
#include <deque> // Para deque (historial)
|
||||||
|
#include <functional> // Para function
|
||||||
#include <memory> // Para shared_ptr
|
#include <memory> // Para shared_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
|
|
||||||
@@ -28,6 +29,9 @@ class Console {
|
|||||||
auto getVisibleHeight() -> int; // Píxeles visibles actuales (0 = oculta, height_ = totalmente visible)
|
auto getVisibleHeight() -> int; // Píxeles visibles actuales (0 = oculta, height_ = totalmente visible)
|
||||||
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; }
|
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; }
|
||||||
|
|
||||||
|
// Callback llamado al abrir (true) o cerrar (false) la consola
|
||||||
|
std::function<void(bool)> on_toggle;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Status {
|
enum class Status {
|
||||||
HIDDEN,
|
HIDDEN,
|
||||||
|
|||||||
Reference in New Issue
Block a user