new: en el mode demo es queda el jugador mort en el terreny de joc

This commit is contained in:
2025-06-30 14:19:55 +02:00
parent ae20181e6f
commit ae8eadb96f
2 changed files with 6 additions and 11 deletions

View File

@@ -187,13 +187,14 @@ void Player::move()
playRandomBubbleSound(); playRandomBubbleSound();
} }
// Si el cadaver toca el suelo cambia el estado // Si el cadaver toca el suelo rebota y si tiene poca velocidad, se detiene y cambia de estado
if (player_sprite_->getPosY() > play_area_.h - HEIGHT_) if (player_sprite_->getPosY() > play_area_.h - HEIGHT_)
{ {
if (player_sprite_->getVelY() < 2.0f) if (player_sprite_->getVelY() < 2.0f)
{ {
// Si la velocidad de rebote es baja, termina de rebotar y cambia de estado // Si la velocidad de rebote es baja, termina de rebotar y cambia de estado
setPlayingState(PlayerState::DIED); const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE;
demo_ ? setPlayingState(PlayerState::LYING_ON_THE_FLOOR_FOREVER) : setPlayingState(nextPlayerStatus);
pos_x_ = player_sprite_->getPosX(); pos_x_ = player_sprite_->getPosX();
pos_y_ = default_pos_y_; pos_y_ = default_pos_y_;
player_sprite_->clear(); player_sprite_->clear();
@@ -381,7 +382,7 @@ void Player::setAnimation()
player_sprite_->setCurrentAnimation("dying"); player_sprite_->setCurrentAnimation("dying");
break; break;
} }
case PlayerState::DIED: case PlayerState::LYING_ON_THE_FLOOR_FOREVER:
case PlayerState::ENTERING_NAME: case PlayerState::ENTERING_NAME:
case PlayerState::CONTINUE: case PlayerState::CONTINUE:
{ {
@@ -544,12 +545,6 @@ void Player::setPlayingState(PlayerState state)
(rand() % 2 == 0) ? player_sprite_->setVelX(3.3f) : player_sprite_->setVelX(-3.3f); (rand() % 2 == 0) ? player_sprite_->setVelX(3.3f) : player_sprite_->setVelX(-3.3f);
break; break;
} }
case PlayerState::DIED:
{
const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE;
demo_ ? setPlayingState(PlayerState::WAITING) : setPlayingState(nextPlayerStatus);
break;
}
case PlayerState::GAME_OVER: case PlayerState::GAME_OVER:
{ {
setScoreboardMode(ScoreboardMode::GAME_OVER); setScoreboardMode(ScoreboardMode::GAME_OVER);

View File

@@ -40,7 +40,7 @@ enum class PlayerState
ENTERING_NAME, // Introduciendo nombre para la tabla de puntuaciones ENTERING_NAME, // Introduciendo nombre para la tabla de puntuaciones
SHOWING_NAME, // Mostrando el nombre introducido SHOWING_NAME, // Mostrando el nombre introducido
DYING, // El jugador está muriendo (animación de muerte) DYING, // El jugador está muriendo (animación de muerte)
DIED, // El jugador ha muerto y ha desaparecido LYING_ON_THE_FLOOR_FOREVER, // El jugador está inconsciente para siempre en el suelo (demo)
GAME_OVER, // Fin de la partida, no puede jugar GAME_OVER, // Fin de la partida, no puede jugar
CELEBRATING, // Celebrando victoria (pose de victoria) CELEBRATING, // Celebrando victoria (pose de victoria)
ENTERING_NAME_GAME_COMPLETED, // Introduciendo nombre tras completar el juego ENTERING_NAME_GAME_COMPLETED, // Introduciendo nombre tras completar el juego
@@ -95,7 +95,7 @@ public:
int getRecordNamePos() const; // Obtiene la posición que se está editando del nombre del jugador para la tabla de mejores puntuaciones int getRecordNamePos() const; // Obtiene la posición que se está editando del nombre del jugador para la tabla de mejores puntuaciones
// Comprobación de playing_state // Comprobación de playing_state
bool hasDied() const { return playing_state_ == PlayerState::DIED; } bool isLyingOnTheFloorForever() const { return playing_state_ == PlayerState::LYING_ON_THE_FLOOR_FOREVER; }
bool isCelebrating() const { return playing_state_ == PlayerState::CELEBRATING; } bool isCelebrating() const { return playing_state_ == PlayerState::CELEBRATING; }
bool isContinue() const { return playing_state_ == PlayerState::CONTINUE; } bool isContinue() const { return playing_state_ == PlayerState::CONTINUE; }
bool isDying() const { return playing_state_ == PlayerState::DYING; } bool isDying() const { return playing_state_ == PlayerState::DYING; }