nou: sonidos de bala diferent per a cada jugador

This commit is contained in:
2025-09-26 20:48:22 +02:00
parent 83871273ec
commit b92e5df98b
6 changed files with 13 additions and 2 deletions

View File

@@ -37,7 +37,8 @@ SOUND|${PREFIX}/data/sound/balloon_pop0.wav
SOUND|${PREFIX}/data/sound/balloon_pop1.wav SOUND|${PREFIX}/data/sound/balloon_pop1.wav
SOUND|${PREFIX}/data/sound/balloon_pop2.wav SOUND|${PREFIX}/data/sound/balloon_pop2.wav
SOUND|${PREFIX}/data/sound/balloon_pop3.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/clock.wav
SOUND|${PREFIX}/data/sound/coffee_out.wav SOUND|${PREFIX}/data/sound/coffee_out.wav
SOUND|${PREFIX}/data/sound/continue_clock.wav SOUND|${PREFIX}/data/sound/continue_clock.wav

BIN
data/sound/bullet2p.wav Normal file

Binary file not shown.

View File

@@ -954,6 +954,11 @@ void Player::setBulletColors(Bullet::Color normal, Bullet::Color powered) {
bullet_colors_.powered_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 // Añade una puntuación a la tabla de records
void Player::addScoreToScoreBoard() const { void Player::addScoreToScoreBoard() const {
if (hi_score_table_ == nullptr) { if (hi_score_table_ == nullptr) {

View File

@@ -199,6 +199,8 @@ class Player {
[[nodiscard]] auto getBulletColor() const -> Bullet::Color; // Devuelve el color actual de bala según el estado [[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) 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 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 // Contadores y timers
[[nodiscard]] auto getContinueCounter() const -> int { return continue_counter_; } [[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 firing_state_ = State::FIRING_NONE; // Estado del jugador al disparar
State playing_state_ = State::WAITING; // Estado del jugador en el juego 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 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 pos_x_ = 0.0F; // Posición en el eje X
float default_pos_x_; // Posición inicial para el jugador float default_pos_x_; // Posición inicial para el jugador

View File

@@ -1349,7 +1349,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, Bullet::Type t
break; break;
} }
createBullet(bullet.x, bullet.y, type, player->getNextBulletColor(), static_cast<int>(player->getId())); createBullet(bullet.x, bullet.y, type, player->getNextBulletColor(), static_cast<int>(player->getId()));
playSound("bullet.wav"); playSound(player->getBulletSoundFile());
// Establece un tiempo de espera para el próximo disparo. // Establece un tiempo de espera para el próximo disparo.
constexpr int POWERUP_COOLDOWN = 5; constexpr int POWERUP_COOLDOWN = 5;
@@ -1636,6 +1636,7 @@ void Game::initPlayers(Player::Id player_id) {
auto player1 = std::make_unique<Player>(config_player1); auto player1 = std::make_unique<Player>(config_player1);
player1->setBulletColors(Bullet::Color::YELLOW, Bullet::Color::GREEN); player1->setBulletColors(Bullet::Color::YELLOW, Bullet::Color::GREEN);
player1->setBulletSoundFile("bullet1p.wav");
player1->setScoreBoardPanel(Scoreboard::Id::LEFT); player1->setScoreBoardPanel(Scoreboard::Id::LEFT);
player1->setName(Lang::getText("[SCOREBOARD] 1")); player1->setName(Lang::getText("[SCOREBOARD] 1"));
player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance); 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<Player>(config_player2); auto player2 = std::make_unique<Player>(config_player2);
player2->setBulletColors(Bullet::Color::RED, Bullet::Color::PURPLE); player2->setBulletColors(Bullet::Color::RED, Bullet::Color::PURPLE);
player2->setBulletSoundFile("bullet2p.wav");
player2->setScoreBoardPanel(Scoreboard::Id::RIGHT); player2->setScoreBoardPanel(Scoreboard::Id::RIGHT);
player2->setName(Lang::getText("[SCOREBOARD] 2")); player2->setName(Lang::getText("[SCOREBOARD] 2"));
player2->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).instance); player2->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).instance);