el joc es pot controlar amb el primer mando que hi haja conectat
This commit is contained in:
@@ -35,18 +35,18 @@ void Player::render() {
|
||||
// Actualiza las variables del objeto
|
||||
void Player::update(float delta_time) {
|
||||
if (!is_paused_) {
|
||||
checkInput(delta_time); // Comprueba las entradas y modifica variables
|
||||
move(delta_time); // Recalcula la posición del jugador
|
||||
animate(delta_time); // Establece la animación del jugador
|
||||
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
||||
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||
checkKillingTiles(); // Comprueba que el jugador no toque ningun tile de los que matan
|
||||
setColor(); // Establece el color del jugador
|
||||
handleInput(delta_time); // Comprueba las entradas y modifica variables
|
||||
move(delta_time); // Recalcula la posición del jugador
|
||||
animate(delta_time); // Establece la animación del jugador
|
||||
handleBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
||||
handleJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||
handleKillingTiles(); // Comprueba que el jugador no toque ningun tile de los que matan
|
||||
setColor(); // Establece el color del jugador
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las entradas y modifica variables
|
||||
void Player::checkInput(float delta_time) {
|
||||
void Player::handleInput(float delta_time) {
|
||||
(void)delta_time; // No usado en este método, pero mantenido para consistencia
|
||||
|
||||
// Solo comprueba las entradas de dirección cuando está sobre una superficie
|
||||
@@ -99,7 +99,7 @@ void Player::checkInput(float delta_time) {
|
||||
}
|
||||
|
||||
// Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
||||
void Player::checkBorders() {
|
||||
void Player::handleBorders() {
|
||||
if (x_ < PLAY_AREA_LEFT) {
|
||||
border_ = Room::Border::LEFT;
|
||||
is_on_border_ = true;
|
||||
@@ -126,7 +126,7 @@ void Player::checkBorders() {
|
||||
}
|
||||
|
||||
// Comprueba el estado del jugador
|
||||
void Player::checkState(float delta_time) {
|
||||
void Player::handleState(float delta_time) {
|
||||
(void)delta_time; // No usado actualmente
|
||||
|
||||
// Reproduce sonidos según el estado
|
||||
@@ -347,7 +347,7 @@ void Player::moveVerticalDown(float delta_time) {
|
||||
// Orquesta el movimiento del jugador
|
||||
void Player::move(float delta_time) {
|
||||
applyGravity(delta_time); // Aplica gravedad al jugador
|
||||
checkState(delta_time); // Comprueba el estado del jugador
|
||||
handleState(delta_time); // Comprueba el estado del jugador
|
||||
|
||||
// Movimiento horizontal
|
||||
if (vx_ < 0.0F) {
|
||||
@@ -388,8 +388,7 @@ void Player::animate(float delta_time) {
|
||||
}
|
||||
|
||||
// Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||
void Player::checkJumpEnd() {
|
||||
// CORRECCIÓN: Usar > (mayor) en lugar de >= (mayor o igual)
|
||||
void Player::handleJumpEnd() {
|
||||
// Si el jugador vuelve EXACTAMENTE a la altura inicial, debe CONTINUAR en JUMPING
|
||||
// Solo cuando la SUPERA (desciende más allá) cambia a FALLING
|
||||
if (state_ == State::JUMPING && vy_ > 0.0F && static_cast<int>(y_) > last_grounded_position_) {
|
||||
@@ -485,7 +484,7 @@ auto Player::isOnDownSlope() -> bool {
|
||||
}
|
||||
|
||||
// Comprueba que el jugador no toque ningun tile de los que matan
|
||||
auto Player::checkKillingTiles() -> bool {
|
||||
auto Player::handleKillingTiles() -> bool {
|
||||
// Comprueba si hay contacto con algún tile que mata
|
||||
if (std::ranges::any_of(collider_points_, [this](const auto& c) {
|
||||
return room_->getTile(c) == Room::Tile::KILL;
|
||||
|
||||
Reference in New Issue
Block a user