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

@@ -635,6 +635,7 @@ void Director::reset()
{ {
Resource::get()->reload(); Resource::get()->reload();
} }
Input::get()->discoverGameControllers();
ServiceMenu::get()->reset(); ServiceMenu::get()->reset();
Section::name = Section::Name::LOGO; Section::name = Section::Name::LOGO;
} }

View File

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

View File

@@ -90,9 +90,9 @@ void Title::render()
tiled_bg_->render(); tiled_bg_->render();
game_logo_->render(); game_logo_->render();
renderPlayers();
renderStartPrompt(); renderStartPrompt();
renderCopyright(); renderCopyright();
renderPlayers();
define_buttons_->render(); define_buttons_->render();
fade_->render(); fade_->render();
@@ -463,12 +463,13 @@ void Title::initPlayers()
// Crea los dos jugadores // Crea los dos jugadores
constexpr int PLAYER_WIDTH = 32; constexpr int PLAYER_WIDTH = 32;
const int Y = param.title.press_start_position; constexpr int PLAYER_HEIGHT = 32;
const int Y = param.title.press_start_position - (PLAYER_HEIGHT / 2);
constexpr bool DEMO = false; constexpr bool DEMO = false;
players_.emplace_back(std::make_unique<Player>(1, param.game.game_area.first_quarter_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(0), player_animations)); players_.emplace_back(std::make_unique<Player>(1, param.game.game_area.center_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(0), player_animations));
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN); players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
players_.emplace_back(std::make_unique<Player>(2, param.game.game_area.third_quarter_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(1), player_animations)); players_.emplace_back(std::make_unique<Player>(2, param.game.game_area.center_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(1), player_animations));
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN); players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
} }