feat(demo): transició per fosa a/desde negre en el salt títol→demo
This commit is contained in:
@@ -37,7 +37,8 @@ namespace {
|
||||
TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
||||
: sdl_(sdl),
|
||||
context_(context),
|
||||
text_(sdl.getRenderer()) {
|
||||
text_(sdl.getRenderer()),
|
||||
fade_(sdl.getRenderer()) {
|
||||
std::cout << "SceneType Titol: Inicialitzant...\n";
|
||||
|
||||
match_config_.player1_active = false;
|
||||
@@ -333,6 +334,9 @@ void TitleScene::update(float delta_time) {
|
||||
case TitleState::BLACK_SCREEN:
|
||||
updateBlackScreenState(delta_time);
|
||||
break;
|
||||
case TitleState::DEMO_FADE_OUT:
|
||||
updateDemoFadeOutState(delta_time);
|
||||
break;
|
||||
}
|
||||
|
||||
// Les animacions segueixen pero els inputs es bloquegen mentre el menu
|
||||
@@ -368,7 +372,12 @@ void TitleScene::update(float delta_time) {
|
||||
demo_cfg.player2_active = (SC.players >= 2);
|
||||
demo_cfg.mode = GameConfig::Mode::DEMO;
|
||||
context_.setMatchConfig(demo_cfg);
|
||||
context_.setNextScene(SceneType::GAME);
|
||||
// No saltem en sec: fosa a negre i, en acabar, canvi a GAME (el salt
|
||||
// real el fa updateDemoFadeOutState). L'estat deixa de ser MAIN, així
|
||||
// que ni es re-dispara la demo ni s'accepta START durant la fosa.
|
||||
current_state_ = TitleState::DEMO_FADE_OUT;
|
||||
fade_.start(0.0F, 1.0F, Defaults::Game::Fade::DEMO_OUT_DURATION);
|
||||
temps_acumulat_ = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,6 +482,13 @@ void TitleScene::updateBlackScreenState(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::updateDemoFadeOutState(float delta_time) {
|
||||
fade_.update(delta_time);
|
||||
if (fade_.isDone()) {
|
||||
context_.setNextScene(SceneType::GAME);
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::handleSkipInput() {
|
||||
if (current_state_ != TitleState::STARFIELD_FADE_IN && current_state_ != TitleState::STARFIELD) {
|
||||
return;
|
||||
@@ -577,7 +593,8 @@ void TitleScene::draw() {
|
||||
(current_state_ == TitleState::STARFIELD_FADE_IN ||
|
||||
current_state_ == TitleState::STARFIELD ||
|
||||
current_state_ == TitleState::MAIN ||
|
||||
current_state_ == TitleState::PLAYER_JOIN_PHASE)) {
|
||||
current_state_ == TitleState::PLAYER_JOIN_PHASE ||
|
||||
current_state_ == TitleState::DEMO_FADE_OUT)) {
|
||||
ship_animator_->draw();
|
||||
}
|
||||
drawFlashes();
|
||||
@@ -586,7 +603,12 @@ void TitleScene::draw() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_state_ != TitleState::MAIN && current_state_ != TitleState::PLAYER_JOIN_PHASE) {
|
||||
// DEMO_FADE_OUT es pinta com MAIN (logo + text) perquè el títol segueixi
|
||||
// visible sota la fosa a negre.
|
||||
if (current_state_ != TitleState::MAIN &&
|
||||
current_state_ != TitleState::PLAYER_JOIN_PHASE &&
|
||||
current_state_ != TitleState::DEMO_FADE_OUT) {
|
||||
fade_.draw(); // BLACK_SCREEN i altres: només la fosa (si activa)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -657,6 +679,9 @@ void TitleScene::draw() {
|
||||
}
|
||||
|
||||
dibuixarPeuTitol(SPACING);
|
||||
|
||||
// Fosa a negre (attract): per damunt de tot. No-op si no està activa.
|
||||
fade_.draw();
|
||||
}
|
||||
|
||||
auto TitleScene::checkSkipButtonPressed() -> bool {
|
||||
|
||||
Reference in New Issue
Block a user