diff --git a/data/gfx/player/player.ani b/data/gfx/player/player.ani index 2cf7e9e..b71632e 100644 --- a/data/gfx/player/player.ani +++ b/data/gfx/player/player.ani @@ -113,6 +113,13 @@ loop=-1 frames=42,42,42,42,42,42,43,44,45,46,46,46,46,46,46,45,45,45,46,46,46,45,45,45,44,43,42,42,42 [/animation] +[animation] +name=thank_you +speed=3 +loop=-1 +frames=42,42,43,44,45,46,46,46,45,44 +[/animation] + [animation] name=dizzy speed=5 diff --git a/source/player.cpp b/source/player.cpp index a288fb6..e2c27c4 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -181,6 +181,9 @@ void Player::move() { case State::WAITING: handleWaitingMovement(); break; + case State::THANK_YOU: + handleThankYouMovement(); + break; default: break; } @@ -198,6 +201,13 @@ void Player::handlePlayingMovement() { shiftSprite(); } +void Player::handleThankYouMovement() { + // Si termina la animacion, cambia de estado + if (player_sprite_->animationIsCompleted()) { + setPlayingState(State::RESPAWNING); + } +} + void Player::handleRollingMovement() { handleRollingBoundaryCollision(); handleRollingGroundCollision(); @@ -465,6 +475,9 @@ void Player::setAnimation() { player_sprite_->setFlip(flipMode); break; } + case State::THANK_YOU: + player_sprite_->setCurrentAnimation("thank_you"); + break; case State::WAITING: case State::GAME_OVER: player_sprite_->setCurrentAnimation("hello"); @@ -627,8 +640,11 @@ void Player::setPlayingState(State state) { playing_state_ = state; switch (playing_state_) { - case State::RESPAWNING: { + case State::THANK_YOU: { playSound("voice_thankyou.wav"); + break; + } + case State::RESPAWNING: { setPlayingState(State::PLAYING); setInvulnerable(true); break; diff --git a/source/player.h b/source/player.h index 871b33f..01e3e5e 100644 --- a/source/player.h +++ b/source/player.h @@ -72,7 +72,8 @@ class Player { CREDITS, // Estado para mostrar los créditos del juego TITLE_ANIMATION, // Animacion para el titulo TITLE_HIDDEN, // Animacion para el titulo - RESPAWNING, // Tras continuar y volver al juego + THANK_YOU, // Al aceptar continuar + RESPAWNING, // Tras continuar y dar las gracias, otorga inmunidad y vuelve al juego }; struct Config { @@ -280,6 +281,7 @@ class Player { void transitionToCooling(); // Cambia el estado actual al de enfriamiento (por ejemplo, tras una ráfaga o sobrecalentamiento) void completeCooling(); // Finaliza el proceso de enfriamiento y restablece el estado listo para disparar void handlePlayingMovement(); // Gestiona el movimiento del personaje u objeto durante el estado de juego activo + void handleThankYouMovement(); // Comprueba si ha acabado la animación void handleRollingMovement(); // Actualiza la lógica de movimiento de "rodar" (posiblemente tras impacto o acción especial) void handleRollingBoundaryCollision(); // Detecta y maneja colisiones del objeto rodante con los límites de la pantalla void handleRollingGroundCollision(); // Gestiona la interacción del objeto rodante con el suelo (rebotes, frenado, etc.) diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 7419ddd..8bfaf84 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -1475,7 +1475,7 @@ void Game::handleFireInputs(const std::shared_ptr &player, bool autofire // Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio. void Game::handlePlayerContinueInput(const std::shared_ptr &player) { if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) { - player->setPlayingState(Player::State::RESPAWNING); + player->setPlayingState(Player::State::THANK_YOU); player->addCredit(); sendPlayerToTheFront(player); // Crea letrero de THANK_YOU