Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <SDL/SDL.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "timer.h"
  5.  
  6. g_timer timer;
  7.  
  8. void do_stuff(Uint32 dt) {
  9.     unsigned int t = 1000 + rand() % 1000000;
  10.    
  11.     printf("Previous dt was %d.\n", dt);
  12.     while (t--);
  13.     return;
  14. }
  15.  
  16. int main(int argc, char **argv) {
  17.     timer_reset(&timer);
  18.     srand(timer.start_ticks);
  19.  
  20.     int quit = 0;
  21.     Uint32 dt = 0;
  22.     SDL_Event event;
  23.  
  24.     SDL_Init(SDL_INIT_EVERYTHING);
  25.  
  26.     while (!quit) {
  27.         timer_reset(&timer);
  28.  
  29.         while (SDL_PollEvent(&event)) {
  30.             if (event.type == SDL_QUIT)
  31.                 quit = 1;
  32.         }
  33.  
  34.         do_stuff(dt);
  35.  
  36.         dt = timer_ticks(&timer);
  37.     }
  38.  
  39.     SDL_Quit();
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement