-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (26 loc) · 779 Bytes
/
main.cpp
File metadata and controls
32 lines (26 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "main.h"
const int FRAMES_PER_SECOND = 60;
int main ( int argc, char** argv ) {
Game game = Game();
if(game.init() > 0 ) {
cout << "Error occured in Game initialization!" << endl;
return 1;
}
game.gs = GS_MAIN;
uint32_t startTicks = SDL_GetTicks();
uint32_t currentTicks = 0;
while (game.gs != GS_DONE) {
if(game.gs == GS_MAIN) {
game.run();
currentTicks = SDL_GetTicks() - startTicks;
if(currentTicks < 1000 / FRAMES_PER_SECOND )
{
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - currentTicks );
startTicks = SDL_GetTicks();
currentTicks = 0;
}
}
}
printf("Exited cleanly\n");
return 0;
}