Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "timer.h"
- g_timer timer;
- void do_stuff(Uint32 dt) {
- unsigned int t = 1000 + rand() % 1000000;
- printf("Previous dt was %d.\n", dt);
- while (t--);
- return;
- }
- int main(int argc, char **argv) {
- timer_reset(&timer);
- srand(timer.start_ticks);
- int quit = 0;
- Uint32 dt = 0;
- SDL_Event event;
- SDL_Init(SDL_INIT_EVERYTHING);
- while (!quit) {
- timer_reset(&timer);
- while (SDL_PollEvent(&event)) {
- if (event.type == SDL_QUIT)
- quit = 1;
- }
- do_stuff(dt);
- dt = timer_ticks(&timer);
- }
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement