Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. int main(int argc, char** argv) {
  2.  
  3.   //atexit(cleanup);
  4.  
  5.   //freopen( "CON", "wt", stdout );
  6.   //freopen( "CON", "wt", stderr );
  7.   /*
  8.   if (argc == 2 && strcmp("--test", argv[1]) == 0) {
  9.     const char* dummy[] = {"", "-v"};
  10.     return CommandLineTestRunner::RunAllTests(2, dummy);
  11.   }*/
  12.  
  13.   //*
  14.   if( init_SDL() != 0) {
  15.     return 1;
  16.   }
  17.  
  18.   Gamestate* gamestate = new Game();
  19.   gamestate->set_next_state(Gamestate::STATE_GAME);
  20.   gamestate->change_state(gamestate);
  21.   int ticks = 0;
  22.   int time = 0;
  23.  
  24.   bool running = true;
  25.   while(running) {
  26.     time = SDL_GetTicks();  
  27.     gamestate->event_handle();
  28.     gamestate->logic();
  29.     gamestate->change_state(gamestate);
  30.    
  31.     glClear(GL_COLOR_BUFFER_BIT );
  32.     glLoadIdentity();
  33.  
  34.     gamestate->render();
  35.     SDL_GL_SwapBuffers();
  36.    
  37.     ticks = SDL_GetTicks();
  38.     if (FPS_TIME > 0 and (ticks - time) <= FPS_TIME) {
  39.             //SDL_Delay(FPS_TIME - (ticks - time));
  40.         }
  41.    
  42.     if (gamestate->get_currentState() == Gamestate::STATE_QUIT)
  43.       running = false;
  44.   }
  45.  
  46.   cleanup();
  47.   //*/
  48.  
  49.   return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement