This commit is contained in:
2025-11-29 12:16:32 +01:00
parent ff8cada8b4
commit bc28a61fad
2 changed files with 43 additions and 17 deletions

1
.gitignore vendored
View File

@ -70,4 +70,5 @@ dist_package/
# Local environment files (if any) # Local environment files (if any)
.env .env
settings.ini
# End of .gitignore # End of .gitignore

View File

@ -753,9 +753,18 @@ int main(int, char **)
SoundEffectManager::instance().loadSound("clear_line", "assets/music/clear_line.wav"); SoundEffectManager::instance().loadSound("clear_line", "assets/music/clear_line.wav");
// Load voice lines for line clears using WAV files (with MP3 fallback) // Load voice lines for line clears using WAV files (with MP3 fallback)
std::vector<std::string> doubleSounds = {"nice_combo", "you_fire", "well_played", "keep_that_ryhtm"}; std::vector<std::string> singleSounds = {"well_played", "smooth_clear", "great_move"};
std::vector<std::string> tripleSounds = {"great_move", "smooth_clear", "impressive", "triple_strike"}; std::vector<std::string> doubleSounds = {"nice_combo", "you_fire", "keep_that_ryhtm"};
std::vector<std::string> tripleSounds = {"impressive", "triple_strike"};
std::vector<std::string> tetrisSounds = {"amazing", "you_re_unstoppable", "boom_tetris", "wonderful"}; std::vector<std::string> tetrisSounds = {"amazing", "you_re_unstoppable", "boom_tetris", "wonderful"};
std::vector<std::string> allVoiceSounds;
auto appendVoices = [&allVoiceSounds](const std::vector<std::string>& src) {
allVoiceSounds.insert(allVoiceSounds.end(), src.begin(), src.end());
};
appendVoices(singleSounds);
appendVoices(doubleSounds);
appendVoices(tripleSounds);
appendVoices(tetrisSounds);
// Helper function to load sound with WAV/MP3 fallback and file existence check // Helper function to load sound with WAV/MP3 fallback and file existence check
auto loadSoundWithFallback = [&](const std::string& id, const std::string& baseName) { auto loadSoundWithFallback = [&](const std::string& id, const std::string& baseName) {
@ -799,20 +808,34 @@ int main(int, char **)
loadSoundWithFallback("wonderful", "wonderful"); loadSoundWithFallback("wonderful", "wonderful");
loadSoundWithFallback("lets_go", "lets_go"); // For level up loadSoundWithFallback("lets_go", "lets_go"); // For level up
// Set up sound effect callbacks auto playVoiceCue = [&](int linesCleared) {
game.setSoundCallback([&](int linesCleared) { const std::vector<std::string>* bank = nullptr;
// Play basic line clear sound first switch (linesCleared) {
SoundEffectManager::instance().playSound("clear_line", 1.0f); // Increased volume case 1: bank = &singleSounds; break;
case 2: bank = &doubleSounds; break;
// Then play voice line based on number of lines cleared case 3: bank = &tripleSounds; break;
if (linesCleared == 2) { default:
SoundEffectManager::instance().playRandomSound(doubleSounds, 1.0f); // Increased volume if (linesCleared >= 4) {
} else if (linesCleared == 3) { bank = &tetrisSounds;
SoundEffectManager::instance().playRandomSound(tripleSounds, 1.0f); // Increased volume
} else if (linesCleared == 4) {
SoundEffectManager::instance().playRandomSound(tetrisSounds, 1.0f); // Increased volume
} }
// Single line clears just play the basic clear sound (no voice in JS version) break;
}
if (bank && !bank->empty()) {
SoundEffectManager::instance().playRandomSound(*bank, 1.0f);
}
};
// Set up sound effect callbacks
game.setSoundCallback([&, playVoiceCue](int linesCleared) {
if (linesCleared <= 0) {
return;
}
// Always play the core line-clear sound for consistency
SoundEffectManager::instance().playSound("clear_line", 1.0f);
// Layer a voiced callout based on the number of cleared lines
playVoiceCue(linesCleared);
}); });
game.setLevelUpCallback([&](int newLevel) { game.setLevelUpCallback([&](int newLevel) {
@ -992,8 +1015,10 @@ int main(int, char **)
} }
if (e.key.scancode == SDL_SCANCODE_N) if (e.key.scancode == SDL_SCANCODE_N)
{ {
// Test sound effects - play lets_go.wav specifically // Manually trigger a random voice line for quick testing
SoundEffectManager::instance().playSound("lets_go", 1.0f); if (!allVoiceSounds.empty()) {
SoundEffectManager::instance().playRandomSound(allVoiceSounds, 1.0f);
}
} }
if (e.key.key == SDLK_F11 || (e.key.key == SDLK_RETURN && (e.key.mod & SDL_KMOD_ALT))) if (e.key.key == SDLK_F11 || (e.key.key == SDLK_RETURN && (e.key.mod & SDL_KMOD_ALT)))
{ {