From 6655ae418cefa43905288fd586ff8932d9325567 Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 28 Apr 2020 17:11:02 -0700 Subject: [PATCH] Update cutscene bars in fixed-timestep loop This prevents cutscene bars from going really really fast. --- desktop_version/src/Graphics.cpp | 19 +++++++++++++++---- desktop_version/src/Graphics.h | 1 + desktop_version/src/main.cpp | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index d092f477..2492c885 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -839,8 +839,6 @@ void Graphics::cutscenebars() { if (showcutscenebars) { - cutscenebarspos += 25; - cutscenebarspos = std::min(cutscenebarspos, 361); FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000); FillRect(backBuffer, 360-cutscenebarspos, 224, cutscenebarspos, 16, 0x000000); } @@ -849,8 +847,6 @@ void Graphics::cutscenebars() //disappearing if (cutscenebarspos > 0) { - cutscenebarspos -= 25; - cutscenebarspos = std::max(cutscenebarspos, 0); //draw FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000); FillRect(backBuffer, 360-cutscenebarspos, 224, cutscenebarspos, 16, 0x000000); @@ -858,6 +854,21 @@ void Graphics::cutscenebars() } } +void Graphics::cutscenebarstimer() +{ + if (showcutscenebars) + { + cutscenebarspos += 25; + cutscenebarspos = std::min(cutscenebarspos, 361); + } + else if (cutscenebarspos > 0) + { + //disappearing + cutscenebarspos -= 25; + cutscenebarspos = std::max(cutscenebarspos, 0); + } +} + void Graphics::drawcrewman( int x, int y, int t, bool act, bool noshift /*=false*/ ) { if (!act) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index e36b28e8..e4a737c2 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -91,6 +91,7 @@ public: int crewcolour(const int t); void cutscenebars(); + void cutscenebarstimer(); void drawpartimage(int t, int xp, int yp, int wp, int hp); diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 8ca1a83e..9d905dac 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -390,6 +390,8 @@ int main(int argc, char *argv[]) Mix_Resume(-1); Mix_ResumeMusic(); game.gametimer++; + graphics.cutscenebarstimer(); + switch(game.gamestate) { case PRELOADER: