fixed
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -70,4 +70,5 @@ dist_package/
|
||||
# Local environment files (if any)
|
||||
.env
|
||||
|
||||
settings.ini
|
||||
# End of .gitignore
|
||||
|
||||
59
src/main.cpp
59
src/main.cpp
@ -753,9 +753,18 @@ int main(int, char **)
|
||||
SoundEffectManager::instance().loadSound("clear_line", "assets/music/clear_line.wav");
|
||||
|
||||
// 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> tripleSounds = {"great_move", "smooth_clear", "impressive", "triple_strike"};
|
||||
std::vector<std::string> singleSounds = {"well_played", "smooth_clear", "great_move"};
|
||||
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> 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
|
||||
auto loadSoundWithFallback = [&](const std::string& id, const std::string& baseName) {
|
||||
@ -799,20 +808,34 @@ int main(int, char **)
|
||||
loadSoundWithFallback("wonderful", "wonderful");
|
||||
loadSoundWithFallback("lets_go", "lets_go"); // For level up
|
||||
|
||||
// Set up sound effect callbacks
|
||||
game.setSoundCallback([&](int linesCleared) {
|
||||
// Play basic line clear sound first
|
||||
SoundEffectManager::instance().playSound("clear_line", 1.0f); // Increased volume
|
||||
|
||||
// Then play voice line based on number of lines cleared
|
||||
if (linesCleared == 2) {
|
||||
SoundEffectManager::instance().playRandomSound(doubleSounds, 1.0f); // Increased volume
|
||||
} else if (linesCleared == 3) {
|
||||
SoundEffectManager::instance().playRandomSound(tripleSounds, 1.0f); // Increased volume
|
||||
} else if (linesCleared == 4) {
|
||||
SoundEffectManager::instance().playRandomSound(tetrisSounds, 1.0f); // Increased volume
|
||||
auto playVoiceCue = [&](int linesCleared) {
|
||||
const std::vector<std::string>* bank = nullptr;
|
||||
switch (linesCleared) {
|
||||
case 1: bank = &singleSounds; break;
|
||||
case 2: bank = &doubleSounds; break;
|
||||
case 3: bank = &tripleSounds; break;
|
||||
default:
|
||||
if (linesCleared >= 4) {
|
||||
bank = &tetrisSounds;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Single line clears just play the basic clear sound (no voice in JS version)
|
||||
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) {
|
||||
@ -992,8 +1015,10 @@ int main(int, char **)
|
||||
}
|
||||
if (e.key.scancode == SDL_SCANCODE_N)
|
||||
{
|
||||
// Test sound effects - play lets_go.wav specifically
|
||||
SoundEffectManager::instance().playSound("lets_go", 1.0f);
|
||||
// Manually trigger a random voice line for quick testing
|
||||
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)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user