-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
35 lines (28 loc) · 896 Bytes
/
main.cpp
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
33
34
35
#include "myfuncs.h" // Custom header file
int main( int argc, char* args[] )
{
srand(time(NULL));
//Quit flag
bool quit=false;
//Frame rate determiner
Uint32 time_now;
if(!init() || !load_files())
return (int)(getErrorCode()); // Initialise and load everything
//While the user hasn't quit
while( quit == false )
{
/** Get current Time.. */
time_now = SDL_GetTicks();
/** Do everything here... */
quit=GameMain();
/**If we have done drawing before the time for 1 frame ends.. */
if( (SDL_GetTicks()-time_now) < 1000 / FRAMES_PER_SECOND )
{
/**Sleep the remaining frame time.. */
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - (SDL_GetTicks()-time_now) );
}
}
//Clean up
clean_up();
return (int)(getErrorCode());
}