Update cutscene bars in fixed-timestep loop

This prevents cutscene bars from going really really fast.
This commit is contained in:
Misa
2020-04-28 17:11:02 -07:00
committed by Ethan Lee
parent a479c61141
commit 6655ae418c
3 changed files with 18 additions and 4 deletions

View File

@@ -839,8 +839,6 @@ void Graphics::cutscenebars()
{ {
if (showcutscenebars) if (showcutscenebars)
{ {
cutscenebarspos += 25;
cutscenebarspos = std::min(cutscenebarspos, 361);
FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000); FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000);
FillRect(backBuffer, 360-cutscenebarspos, 224, cutscenebarspos, 16, 0x000000); FillRect(backBuffer, 360-cutscenebarspos, 224, cutscenebarspos, 16, 0x000000);
} }
@@ -849,8 +847,6 @@ void Graphics::cutscenebars()
//disappearing //disappearing
if (cutscenebarspos > 0) if (cutscenebarspos > 0)
{ {
cutscenebarspos -= 25;
cutscenebarspos = std::max(cutscenebarspos, 0);
//draw //draw
FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000); FillRect(backBuffer, 0, 0, cutscenebarspos, 16, 0x000000);
FillRect(backBuffer, 360-cutscenebarspos, 224, 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*/ ) void Graphics::drawcrewman( int x, int y, int t, bool act, bool noshift /*=false*/ )
{ {
if (!act) if (!act)

View File

@@ -91,6 +91,7 @@ public:
int crewcolour(const int t); int crewcolour(const int t);
void cutscenebars(); void cutscenebars();
void cutscenebarstimer();
void drawpartimage(int t, int xp, int yp, int wp, int hp); void drawpartimage(int t, int xp, int yp, int wp, int hp);

View File

@@ -390,6 +390,8 @@ int main(int argc, char *argv[])
Mix_Resume(-1); Mix_Resume(-1);
Mix_ResumeMusic(); Mix_ResumeMusic();
game.gametimer++; game.gametimer++;
graphics.cutscenebarstimer();
switch(game.gamestate) switch(game.gamestate)
{ {
case PRELOADER: case PRELOADER: