diff --git a/source/director.cpp b/source/director.cpp index 6a3512b..592e24a 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -635,6 +635,7 @@ void Director::reset() { Resource::get()->reload(); } + Input::get()->discoverGameControllers(); ServiceMenu::get()->reset(); Section::name = Section::Name::LOGO; } diff --git a/source/player.cpp b/source/player.cpp index 5b28530..6440804 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -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; } diff --git a/source/sections/title.cpp b/source/sections/title.cpp index 0e07bb9..f2d3db8 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -90,9 +90,9 @@ void Title::render() tiled_bg_->render(); game_logo_->render(); + renderPlayers(); renderStartPrompt(); renderCopyright(); - renderPlayers(); define_buttons_->render(); fade_->render(); @@ -463,12 +463,13 @@ void Title::initPlayers() // Crea los dos jugadores 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; - players_.emplace_back(std::make_unique(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(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_.emplace_back(std::make_unique(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(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); }