feat(title): música title.ogg amb fade-out, SFX player_start al START i bombament continu del stream sortint per evitar talls quan SDL drena a 2x
This commit is contained in:
1 parent
36fc496226
commit
921e10bbb3
10 files changed
+109
-1
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/input/gamepad_bindings.hpp"
|
||||
#include "core/input/gamepad_manager.hpp"
|
||||
#include "core/input/global_inputs.hpp"
|
||||
@@ -69,6 +70,15 @@ namespace {
|
||||
return font.getLineHeight();
|
||||
}
|
||||
|
||||
// Reproducció del so de START. Centralitzat ací per disparar-lo des
|
||||
// dels punts on una pulsació té efecte real (entrada a STARTING o
|
||||
// upgrade a BOTH); l'attract timeout no l'ha de tocar.
|
||||
void playStartSound() {
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->playSound(UiConfig::get().playerStartSound(), Audio::Group::INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TitleScene::TitleScene(std::shared_ptr<Text> display_font, std::shared_ptr<Text> condensed_font, std::shared_ptr<Surface> background, std::shared_ptr<Surface> mini_logo, SceneFactory next_factory)
|
||||
@@ -90,6 +100,13 @@ TitleScene::TitleScene(std::shared_ptr<Text> display_font, std::shared_ptr<Text>
|
||||
fade_out_.emplace(Transitions::Mosaic::Params{
|
||||
.max_block_size = UiConfig::get().titleFadeOutMaxBlock(),
|
||||
});
|
||||
|
||||
// Música de fons en bucle. Es preloda al Director, així que la
|
||||
// primera crida és immediata. El fade-out arrenca en entrar a
|
||||
// STARTING (vore enterStarting).
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->playMusic("title.ogg", -1);
|
||||
}
|
||||
}
|
||||
|
||||
TitleScene::~TitleScene() = default;
|
||||
@@ -117,8 +134,10 @@ void TitleScene::update(int delta_ms) {
|
||||
case Phase::IDLE: {
|
||||
timer_ms_ -= delta_ms;
|
||||
if (P1_START) {
|
||||
playStartSound();
|
||||
enterStarting(DebugConfig::StartingPlayers::P1);
|
||||
} else if (P2_START) {
|
||||
playStartSound();
|
||||
enterStarting(DebugConfig::StartingPlayers::P2);
|
||||
} else if (timer_ms_ <= 0) {
|
||||
// Attract: ningú ha premut. Entrem a STARTING amb BOTH
|
||||
@@ -140,6 +159,7 @@ void TitleScene::update(int delta_ms) {
|
||||
(pending_players_ == DebugConfig::StartingPlayers::P2 && P1_START);
|
||||
const bool FADE_LOCKED = fade_out_ && (fade_out_->isActive() || fade_out_->isFinished());
|
||||
if (OTHER_PRESSED && !FADE_LOCKED) {
|
||||
playStartSound();
|
||||
pending_players_ = DebugConfig::StartingPlayers::BOTH;
|
||||
starting_timer_ms_ = UiConfig::get().titleStartingMs();
|
||||
}
|
||||
@@ -172,6 +192,12 @@ void TitleScene::enterStarting(DebugConfig::StartingPlayers players) {
|
||||
// STARTING comenci visible — sense això, el modulus amb el nou
|
||||
// període podria caure mig cicle i donar un primer "off" estrany.
|
||||
blink_elapsed_ms_ = 0;
|
||||
// Fade-out de la música. Si l'altre jugador prem START i el timer
|
||||
// es reseteja, no rearranquem la música: es manté la fosa iniciada
|
||||
// ací (consistent amb el fade visual, que tampoc es reverteix).
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->fadeOutMusic(UiConfig::get().titleMusicFadeOutMs());
|
||||
}
|
||||
std::cout << "[scene] " << SCENE_NAME << " STARTING (players=" << DebugConfig::toString(players) << ")\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user