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; 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[]) int main(int argc, char *argv[])
{ {
char* baseDir = NULL; char* baseDir = NULL;
@ -303,12 +312,6 @@ int main(int argc, char *argv[])
} }
#endif #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; game.infocus = true;
key.isActive = true; key.isActive = true;
game.gametimer = 0; game.gametimer = 0;
@ -323,6 +326,19 @@ int main(int argc, char *argv[])
f_accumulator += f_rawdeltatime; 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) while ((game.over30mode || f_accumulator >= 34) && !key.quitProgram)
{ {
if (game.over30mode) if (game.over30mode)
@ -624,12 +640,4 @@ int main(int argc, char *argv[])
gameScreen.FlipScreen(); gameScreen.FlipScreen();
} }
} }
}
game.savestats();
NETWORK_shutdown();
SDL_Quit();
FILESYSTEM_deinit();
return 0;
} }