time-based: migrada escena Instructions + fix scroll diagonal del fons del Title (ancorat a posicio inicial)
This commit is contained in:
@@ -638,13 +638,15 @@ void Title::checkInput() {
|
||||
void Title::updateBG(float dt_s) {
|
||||
if (background_mode_ == 0) {
|
||||
// Diagonal: 60 px/s a 60Hz ⇒ un cicle de 64 px cada 64/60 = 1.067 s.
|
||||
// Ancorat a la posició inicial (128, 96): t=0 dona la mateixa vista que
|
||||
// l'estàtic dels Title1/Title2, sense salt visual a l'entrada del Title3.
|
||||
constexpr float SCROLL_PERIOD_S = 64.0F / BG_SCROLL_SPEED_PX_PER_S;
|
||||
bg_scroll_x_s_ += dt_s;
|
||||
bg_scroll_y_s_ += dt_s;
|
||||
if (bg_scroll_x_s_ >= SCROLL_PERIOD_S) { bg_scroll_x_s_ -= SCROLL_PERIOD_S; }
|
||||
if (bg_scroll_y_s_ >= SCROLL_PERIOD_S) { bg_scroll_y_s_ -= SCROLL_PERIOD_S; }
|
||||
background_window_.x = static_cast<int>(bg_scroll_x_s_ * BG_SCROLL_SPEED_PX_PER_S);
|
||||
background_window_.y = static_cast<int>(bg_scroll_y_s_ * BG_SCROLL_SPEED_PX_PER_S);
|
||||
background_window_.x = 128 + static_cast<int>(bg_scroll_x_s_ * BG_SCROLL_SPEED_PX_PER_S);
|
||||
background_window_.y = 96 + static_cast<int>(bg_scroll_y_s_ * BG_SCROLL_SPEED_PX_PER_S);
|
||||
} else {
|
||||
// Cercle: 360 graus en BG_CIRCLE_PERIOD_S segons.
|
||||
bg_phase_s_ += dt_s;
|
||||
@@ -851,9 +853,11 @@ void Title::applyOptions() {
|
||||
|
||||
// Ejecuta un frame
|
||||
void Title::iterate() {
|
||||
const float DELTA_TIME_S = DeltaTime::tick();
|
||||
|
||||
// Si las instrucciones están activas, delega el frame
|
||||
if (instructions_active_) {
|
||||
instructions_->update();
|
||||
instructions_->update(DELTA_TIME_S);
|
||||
instructions_->render();
|
||||
|
||||
if (instructions_->hasFinished()) {
|
||||
@@ -872,6 +876,8 @@ void Title::iterate() {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_3;
|
||||
}
|
||||
// Reset del rellotge per evitar un dt enorme al tornar al Title.
|
||||
DeltaTime::reset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -901,6 +907,8 @@ void Title::iterate() {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
// Reset del rellotge per evitar un dt enorme al tornar al Title.
|
||||
DeltaTime::reset();
|
||||
} else {
|
||||
// Restaura section para que Director no transicione fuera de Title
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
@@ -909,7 +917,6 @@ void Title::iterate() {
|
||||
}
|
||||
|
||||
// Ejecución normal del título
|
||||
const float DELTA_TIME_S = DeltaTime::tick();
|
||||
update(DELTA_TIME_S);
|
||||
render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user