1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-10 19:09:45 +01:00

Put the main game loop inside its own function

Makes main() less of one giant blob of code.
This commit is contained in:
Misa 2020-06-14 11:45:36 -07:00 committed by Ethan Lee
parent 3d674a6550
commit a8d2994223

View file

@ -56,6 +56,15 @@ int savemusic = 0;
std::string playtestname;
volatile Uint32 time_ = 0;
volatile Uint32 timePrev = 0;
volatile Uint32 accumulator = 0;
volatile Uint32 f_time = 0;
volatile Uint32 f_timePrev = 0;
volatile Uint32 f_accumulator = 0;
void gameloop();
int main(int argc, char *argv[])
{
char* baseDir = NULL;
@ -303,12 +312,6 @@ int main(int argc, char *argv[])
}
#endif
volatile Uint32 time_ = 0;
volatile Uint32 timePrev = 0;
volatile Uint32 accumulator = 0;
volatile Uint32 f_time = 0;
volatile Uint32 f_timePrev = 0;
volatile Uint32 f_accumulator = 0;
game.infocus = true;
key.isActive = true;
game.gametimer = 0;
@ -323,6 +326,19 @@ int main(int argc, char *argv[])
f_accumulator += f_rawdeltatime;
}
gameloop();
}
game.savestats();
NETWORK_shutdown();
SDL_Quit();
FILESYSTEM_deinit();
return 0;
}
void gameloop()
{
while ((game.over30mode || f_accumulator >= 34) && !key.quitProgram)
{
if (game.over30mode)
@ -625,11 +641,3 @@ int main(int argc, char *argv[])
}
}
}
game.savestats();
NETWORK_shutdown();
SDL_Quit();
FILESYSTEM_deinit();
return 0;
}