1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Move fixed loop to its own function

To improve code readability because otherwise the code would be one
giant blob.
This commit is contained in:
Misa 2020-06-14 11:57:33 -07:00 committed by Ethan Lee
parent 1fbec9c427
commit a9f07ccc8f

View file

@ -65,6 +65,7 @@ volatile Uint32 f_accumulator = 0;
void gameloop(); void gameloop();
void deltaloop(); void deltaloop();
void fixedloop();
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -387,6 +388,50 @@ void deltaloop()
{ {
accumulator = fmodf(accumulator, timesteplimit); accumulator = fmodf(accumulator, timesteplimit);
fixedloop();
}
const float alpha = game.over30mode ? static_cast<float>(accumulator) / timesteplimit : 1.0f;
graphics.alpha = alpha;
if (game.infocus)
{
switch (game.gamestate)
{
case PRELOADER:
preloaderrender();
break;
case EDITORMODE:
graphics.flipmode = false;
editorrender();
break;
case TITLEMODE:
titlerender();
break;
case GAMEMODE:
gamerender();
break;
case MAPMODE:
maprender();
break;
case TELEPORTERMODE:
teleporterrender();
break;
case GAMECOMPLETE:
gamecompleterender();
break;
case GAMECOMPLETE2:
gamecompleterender2();
break;
case CLICKTOSTART:
help.updateglow();
break;
}
gameScreen.FlipScreen();
}
}
void fixedloop()
{
key.Poll(); key.Poll();
if(key.toggleFullscreen) if(key.toggleFullscreen)
{ {
@ -607,43 +652,4 @@ void deltaloop()
music.processmusic(); music.processmusic();
graphics.processfade(); graphics.processfade();
game.gameclock(); game.gameclock();
}
const float alpha = game.over30mode ? static_cast<float>(accumulator) / timesteplimit : 1.0f;
graphics.alpha = alpha;
if (game.infocus)
{
switch (game.gamestate)
{
case PRELOADER:
preloaderrender();
break;
case EDITORMODE:
graphics.flipmode = false;
editorrender();
break;
case TITLEMODE:
titlerender();
break;
case GAMEMODE:
gamerender();
break;
case MAPMODE:
maprender();
break;
case TELEPORTERMODE:
teleporterrender();
break;
case GAMECOMPLETE:
gamecompleterender();
break;
case GAMECOMPLETE2:
gamecompleterender2();
break;
case CLICKTOSTART:
help.updateglow();
break;
}
gameScreen.FlipScreen();
}
} }