modificada la animació del titol per començar a jugar

This commit is contained in:
2025-07-14 17:17:49 +02:00
parent 72d2525e61
commit 1d3b016b85
3 changed files with 35 additions and 14 deletions

View File

@@ -219,7 +219,7 @@ void Player::move()
case PlayerState::TITLE_ANIMATION:
{
// Si el jugador abandona el area de juego por los laterales lo detiene
const int X = player_sprite_->getPosX();
/*const int X = player_sprite_->getPosX();
const int MIN_X = play_area_.x - WIDTH_;
const int MAX_X = play_area_.x + play_area_.w;
if ((X < MIN_X) || (X > MAX_X))
@@ -229,6 +229,28 @@ void Player::move()
// Si el jugador toca el suelo rebota lo detiene
if (player_sprite_->getPosY() > play_area_.h)
{
setPlayingState(PlayerState::TITLE_HIDDEN);
}*/
switch (id_)
{
case 1:
setInputPlaying(InputAction::LEFT);
break;
case 2:
setInputPlaying(InputAction::RIGHT);
break;
default:
break;
}
pos_x_ += vel_x_ * 2.0f;
const float MIN_X = -WIDTH_;
const float MAX_X = play_area_.w;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
if (pos_x_ == MIN_X || pos_x_ == MAX_X)
{
setPlayingState(PlayerState::TITLE_HIDDEN);
}
@@ -263,12 +285,12 @@ void Player::move()
break;
}
pos_x_ += vel_x_;
const float min_x = -WIDTH_;
const float max_x = play_area_.w;
pos_x_ = std::clamp(pos_x_, min_x, max_x);
const float MIN_X = -WIDTH_;
const float MAX_X = play_area_.w;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
if (pos_x_ == min_x || pos_x_ == max_x)
if (pos_x_ == MIN_X || pos_x_ == MAX_X)
{
setPlayingState(PlayerState::GAME_OVER);
}
@@ -374,6 +396,7 @@ void Player::setAnimation()
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
case PlayerState::ENTERING_SCREEN:
case PlayerState::LEAVING_SCREEN:
case PlayerState::TITLE_ANIMATION:
case PlayerState::CREDITS:
{
// Crea cadenas de texto para componer el nombre de la animación
@@ -418,7 +441,6 @@ void Player::setAnimation()
}
case PlayerState::ROLLING:
case PlayerState::CONTINUE_TIME_OUT:
case PlayerState::TITLE_ANIMATION:
{
player_sprite_->setCurrentAnimation("rolling");
break;
@@ -638,10 +660,7 @@ void Player::setPlayingState(PlayerState state)
case PlayerState::TITLE_ANIMATION:
{
// Activa la animación de rodar
player_sprite_->setCurrentAnimation("rolling");
player_sprite_->setAnimationSpeed(5);
player_sprite_->setAccelY(0.2f);
player_sprite_->setVelY(-6.6f);
player_sprite_->setCurrentAnimation("walk");
playSound("voice_thankyou.wav");
break;
}