Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. #include "SDL.h"
  5.  
  6. static int oldtime;
  7. static int newtime;
  8.  
  9. int timer (int interval)
  10. {
  11.   return (oldtime/interval) != (newtime/interval);
  12. }
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.   ...
  17.  
  18.   for (;;)
  19.     {
  20.       oldtime = newtime;
  21.       newtime = SDL_GetTicks ();
  22.  
  23.       if (timer (1000))
  24.     {
  25.       fputs ("1000\n", stdout);
  26.     }
  27.       if (timer (2000))
  28.     {
  29.       fputs ("2000\n", stdout);
  30.     }
  31.       if (timer (3000))
  32.     {
  33.       fputs ("3000\n", stdout);
  34.     }
  35.     }
  36.   ...
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement