diff --git a/config/assets.txt b/config/assets.txt index 9f00f19..67c9780 100644 --- a/config/assets.txt +++ b/config/assets.txt @@ -37,7 +37,8 @@ SOUND|${PREFIX}/data/sound/balloon_pop0.wav SOUND|${PREFIX}/data/sound/balloon_pop1.wav SOUND|${PREFIX}/data/sound/balloon_pop2.wav SOUND|${PREFIX}/data/sound/balloon_pop3.wav -SOUND|${PREFIX}/data/sound/bullet.wav +SOUND|${PREFIX}/data/sound/bullet1p.wav +SOUND|${PREFIX}/data/sound/bullet2p.wav SOUND|${PREFIX}/data/sound/clock.wav SOUND|${PREFIX}/data/sound/coffee_out.wav SOUND|${PREFIX}/data/sound/continue_clock.wav diff --git a/data/sound/bullet.wav b/data/sound/bullet1p.wav similarity index 100% rename from data/sound/bullet.wav rename to data/sound/bullet1p.wav diff --git a/data/sound/bullet2p.wav b/data/sound/bullet2p.wav new file mode 100644 index 0000000..3d376a9 Binary files /dev/null and b/data/sound/bullet2p.wav differ diff --git a/source/player.cpp b/source/player.cpp index c42a5bc..c7285e9 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -954,6 +954,11 @@ void Player::setBulletColors(Bullet::Color normal, Bullet::Color powered) { bullet_colors_.powered_color = powered; } +// Establece el archivo de sonido de bala para este jugador +void Player::setBulletSoundFile(const std::string& filename) { + bullet_sound_file_ = filename; +} + // Añade una puntuación a la tabla de records void Player::addScoreToScoreBoard() const { if (hi_score_table_ == nullptr) { diff --git a/source/player.h b/source/player.h index e681f6d..7bc14cb 100644 --- a/source/player.h +++ b/source/player.h @@ -199,6 +199,8 @@ class Player { [[nodiscard]] auto getBulletColor() const -> Bullet::Color; // Devuelve el color actual de bala según el estado auto getNextBulletColor() -> Bullet::Color; // Devuelve el color para la próxima bala (alterna si está en modo toggle) void setBulletColors(Bullet::Color normal, Bullet::Color powered); // Establece los colores de bala para este jugador + [[nodiscard]] auto getBulletSoundFile() const -> std::string { return bullet_sound_file_; } // Devuelve el archivo de sonido de bala + void setBulletSoundFile(const std::string& filename); // Establece el archivo de sonido de bala para este jugador // Contadores y timers [[nodiscard]] auto getContinueCounter() const -> int { return continue_counter_; } @@ -257,6 +259,7 @@ class Player { State firing_state_ = State::FIRING_NONE; // Estado del jugador al disparar State playing_state_ = State::WAITING; // Estado del jugador en el juego BulletColorPair bullet_colors_ = {Bullet::Color::YELLOW, Bullet::Color::GREEN}; // Par de colores de balas para este jugador + std::string bullet_sound_file_ = "bullet1p.wav"; // Archivo de sonido de bala para este jugador float pos_x_ = 0.0F; // Posición en el eje X float default_pos_x_; // Posición inicial para el jugador diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 826d3af..a276c44 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -1349,7 +1349,7 @@ void Game::handleFireInput(const std::shared_ptr &player, Bullet::Type t break; } createBullet(bullet.x, bullet.y, type, player->getNextBulletColor(), static_cast(player->getId())); - playSound("bullet.wav"); + playSound(player->getBulletSoundFile()); // Establece un tiempo de espera para el próximo disparo. constexpr int POWERUP_COOLDOWN = 5; @@ -1636,6 +1636,7 @@ void Game::initPlayers(Player::Id player_id) { auto player1 = std::make_unique(config_player1); player1->setBulletColors(Bullet::Color::YELLOW, Bullet::Color::GREEN); + player1->setBulletSoundFile("bullet1p.wav"); player1->setScoreBoardPanel(Scoreboard::Id::LEFT); player1->setName(Lang::getText("[SCOREBOARD] 1")); player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance); @@ -1657,6 +1658,7 @@ void Game::initPlayers(Player::Id player_id) { auto player2 = std::make_unique(config_player2); player2->setBulletColors(Bullet::Color::RED, Bullet::Color::PURPLE); + player2->setBulletSoundFile("bullet2p.wav"); player2->setScoreBoardPanel(Scoreboard::Id::RIGHT); player2->setName(Lang::getText("[SCOREBOARD] 2")); player2->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).instance);