nou: musica al completar el joc
This commit is contained in:
@@ -22,6 +22,7 @@ DEMODATA|${PREFIX}/data/demo/demo1.bin
|
||||
DEMODATA|${PREFIX}/data/demo/demo2.bin
|
||||
|
||||
# Música
|
||||
MUSIC|${PREFIX}/data/music/congratulations.ogg
|
||||
MUSIC|${PREFIX}/data/music/credits.ogg
|
||||
MUSIC|${PREFIX}/data/music/intro.ogg
|
||||
MUSIC|${PREFIX}/data/music/playing.ogg
|
||||
|
||||
@@ -109,7 +109,7 @@ frames=38,39,40,41
|
||||
[animation]
|
||||
name=celebration
|
||||
speed=0.167
|
||||
loop=-1
|
||||
loop=0
|
||||
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]
|
||||
|
||||
|
||||
BIN
data/music/congratulations.ogg
Normal file
BIN
data/music/congratulations.ogg
Normal file
Binary file not shown.
@@ -13,7 +13,6 @@ void ManageHiScoreTable::clear() {
|
||||
table_.clear();
|
||||
|
||||
// Añade 10 entradas predefinidas
|
||||
/*
|
||||
table_.emplace_back("BRY", 1000000);
|
||||
table_.emplace_back("USUFO", 500000);
|
||||
table_.emplace_back("GLUCA", 100000);
|
||||
@@ -24,8 +23,8 @@ void ManageHiScoreTable::clear() {
|
||||
table_.emplace_back("SAM", 500);
|
||||
table_.emplace_back("PACMQ", 200);
|
||||
table_.emplace_back("PELEC", 100);
|
||||
*/
|
||||
|
||||
/*
|
||||
table_.emplace_back("BRY", 1000);
|
||||
table_.emplace_back("USUFO", 500);
|
||||
table_.emplace_back("GLUCA", 100);
|
||||
@@ -36,6 +35,20 @@ void ManageHiScoreTable::clear() {
|
||||
table_.emplace_back("SAM", 3);
|
||||
table_.emplace_back("PACMQ", 2);
|
||||
table_.emplace_back("PELEC", 1);
|
||||
*/
|
||||
|
||||
/*
|
||||
table_.emplace_back("BRY", 5000000);
|
||||
table_.emplace_back("USUFO", 5000000);
|
||||
table_.emplace_back("GLUCA", 5000000);
|
||||
table_.emplace_back("PARRA", 5000000);
|
||||
table_.emplace_back("CAGAM", 5000000);
|
||||
table_.emplace_back("PEPE", 5000000);
|
||||
table_.emplace_back("ROSIT", 5000000);
|
||||
table_.emplace_back("SAM", 5000000);
|
||||
table_.emplace_back("PACMQ", 5000000);
|
||||
table_.emplace_back("PELEC", 5000000);
|
||||
*/
|
||||
|
||||
sort();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ void Player::setInputEnteringName(Input::Action action) {
|
||||
name_entry_idle_time_accumulator_ = 0.0f;
|
||||
}
|
||||
|
||||
// Fase 1: Sistema de movimiento time-based
|
||||
// Sistema de movimiento
|
||||
void Player::move(float deltaTime) {
|
||||
switch (playing_state_) {
|
||||
case State::PLAYING:
|
||||
@@ -475,11 +475,10 @@ auto Player::computeAnimation() const -> std::pair<std::string, SDL_FlipMode> {
|
||||
return {anim_name, flip_mode};
|
||||
}
|
||||
|
||||
// Fase 1: Establece la animación correspondiente al estado (time-based)
|
||||
// Establece la animación correspondiente al estado
|
||||
void Player::setAnimation(float deltaTime) {
|
||||
switch (playing_state_) {
|
||||
case State::PLAYING:
|
||||
case State::ENTERING_NAME_GAME_COMPLETED:
|
||||
case State::ENTERING_SCREEN:
|
||||
case State::LEAVING_SCREEN:
|
||||
case State::TITLE_ANIMATION:
|
||||
@@ -505,6 +504,7 @@ void Player::setAnimation(float deltaTime) {
|
||||
case State::CONTINUE:
|
||||
player_sprite_->setCurrentAnimation("dizzy");
|
||||
break;
|
||||
case State::ENTERING_NAME_GAME_COMPLETED:
|
||||
case State::CELEBRATING:
|
||||
player_sprite_->setCurrentAnimation("celebration");
|
||||
break;
|
||||
@@ -679,8 +679,8 @@ void Player::setPlayingState(State state) {
|
||||
break;
|
||||
}
|
||||
case State::ENTERING_NAME_GAME_COMPLETED: {
|
||||
setWalkingState(State::WALKING_STOP);
|
||||
setFiringState(State::FIRING_NONE);
|
||||
// setWalkingState(State::WALKING_STOP);
|
||||
// setFiringState(State::FIRING_NONE);
|
||||
setScoreboardMode(Scoreboard::Mode::ENTER_NAME);
|
||||
break;
|
||||
}
|
||||
@@ -1034,19 +1034,35 @@ void Player::updateFiringStateFromVisual() {
|
||||
|
||||
case VisualFireState::RECOILING:
|
||||
switch (base_state) {
|
||||
case State::FIRING_LEFT: firing_state_ = State::RECOILING_LEFT; break;
|
||||
case State::FIRING_RIGHT: firing_state_ = State::RECOILING_RIGHT; break;
|
||||
case State::FIRING_UP: firing_state_ = State::RECOILING_UP; break;
|
||||
default: firing_state_ = State::RECOILING_UP; break;
|
||||
case State::FIRING_LEFT:
|
||||
firing_state_ = State::RECOILING_LEFT;
|
||||
break;
|
||||
case State::FIRING_RIGHT:
|
||||
firing_state_ = State::RECOILING_RIGHT;
|
||||
break;
|
||||
case State::FIRING_UP:
|
||||
firing_state_ = State::RECOILING_UP;
|
||||
break;
|
||||
default:
|
||||
firing_state_ = State::RECOILING_UP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case VisualFireState::THREAT_POSE:
|
||||
switch (base_state) {
|
||||
case State::FIRING_LEFT: firing_state_ = State::COOLING_LEFT; break;
|
||||
case State::FIRING_RIGHT: firing_state_ = State::COOLING_RIGHT; break;
|
||||
case State::FIRING_UP: firing_state_ = State::COOLING_UP; break;
|
||||
default: firing_state_ = State::COOLING_UP; break;
|
||||
case State::FIRING_LEFT:
|
||||
firing_state_ = State::COOLING_LEFT;
|
||||
break;
|
||||
case State::FIRING_RIGHT:
|
||||
firing_state_ = State::COOLING_RIGHT;
|
||||
break;
|
||||
case State::FIRING_UP:
|
||||
firing_state_ = State::COOLING_UP;
|
||||
break;
|
||||
default:
|
||||
firing_state_ = State::COOLING_UP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ void Game::initPaths() {
|
||||
const int X0 = -W;
|
||||
const int X1 = param.game.play_area.center_x - (W / 2);
|
||||
const int X2 = param.game.play_area.rect.w;
|
||||
const int Y = param.game.play_area.center_y - (H / 2) - 20;
|
||||
const int Y = param.game.play_area.center_y - (H / 2);
|
||||
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 7.0F);
|
||||
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
|
||||
}
|
||||
@@ -1074,7 +1074,7 @@ void Game::initPaths() {
|
||||
const int X0 = param.game.play_area.rect.w;
|
||||
const int X1 = param.game.play_area.center_x - (W / 2);
|
||||
const int X2 = -W;
|
||||
const int Y = param.game.play_area.center_y + (H / 2) - 20;
|
||||
const int Y = param.game.play_area.center_y + (H / 2);
|
||||
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 7.0F);
|
||||
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
|
||||
}
|
||||
@@ -1083,10 +1083,11 @@ void Game::initPaths() {
|
||||
{
|
||||
const auto &texture = Resource::get()->getTexture("game_text_new_record");
|
||||
const auto W = texture->getWidth();
|
||||
const auto H = texture->getHeight();
|
||||
const int X0 = -W;
|
||||
const int X1 = param.game.play_area.center_x - (W / 2);
|
||||
const int X2 = param.game.play_area.rect.w;
|
||||
const int Y = param.game.play_area.first_quarter_y;
|
||||
const int Y = param.game.play_area.center_y - (H / 2) - (H * 2);
|
||||
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 1.0f);
|
||||
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
|
||||
}
|
||||
@@ -1658,8 +1659,8 @@ void Game::initPlayers(Player::Id player_id) {
|
||||
}
|
||||
|
||||
// Hace sonar la música
|
||||
void Game::playMusic() {
|
||||
Audio::get()->playMusic("playing.ogg");
|
||||
void Game::playMusic(const std::string &music_file, int loop) {
|
||||
Audio::get()->playMusic(music_file, loop);
|
||||
}
|
||||
|
||||
// Pausa la música
|
||||
@@ -1770,7 +1771,7 @@ void Game::updateGameStateShowingGetReadyMessage(float deltaTime) {
|
||||
if (!music_started) {
|
||||
music_timer += deltaTime;
|
||||
if (music_timer >= 1.67f) {
|
||||
playMusic();
|
||||
playMusic("playing.ogg");
|
||||
music_started = true;
|
||||
setState(State::PLAYING);
|
||||
}
|
||||
@@ -1781,7 +1782,7 @@ void Game::updateGameStateShowingGetReadyMessage(float deltaTime) {
|
||||
void Game::updateGameStatePlaying(float deltaTime) {
|
||||
#ifdef _DEBUG
|
||||
if (auto_pop_balloons_) {
|
||||
stage_manager_->addPower(1);
|
||||
stage_manager_->addPower(2);
|
||||
}
|
||||
#endif
|
||||
updatePlayers(deltaTime);
|
||||
@@ -1935,8 +1936,8 @@ void Game::onPauseStateChanged(bool is_paused) {
|
||||
|
||||
// Maneja eventos del juego completado usando flags para triggers únicos
|
||||
void Game::handleGameCompletedEvents() {
|
||||
constexpr float START_CELEBRATIONS_S = 6.667f; // 400 frames a 60fps → segundos
|
||||
constexpr float END_CELEBRATIONS_S = 11.667f; // 700 frames a 60fps → segundos
|
||||
constexpr float START_CELEBRATIONS_S = 6.0f;
|
||||
constexpr float END_CELEBRATIONS_S = 14.0f;
|
||||
|
||||
// Inicio de celebraciones
|
||||
static bool start_celebrations_triggered = false;
|
||||
@@ -1954,6 +1955,7 @@ void Game::handleGameCompletedEvents() {
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
playMusic("congratulations.ogg", 1);
|
||||
start_celebrations_triggered = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ class Game {
|
||||
void updateHelper(); // Actualiza variables auxiliares de renderizado
|
||||
|
||||
// --- Sistema de audio ---
|
||||
static void playMusic(); // Reproduce la música de fondo
|
||||
static void playMusic(const std::string &music_file, int loop = -1); // Reproduce la música de fondo
|
||||
void stopMusic() const; // Detiene la reproducción de música
|
||||
static void pauseMusic(); // Pausa la música
|
||||
static void resumeMusic(); // Retoma la música que eestaba pausada
|
||||
|
||||
Reference in New Issue
Block a user