Index: game.c ================================================================== --- game.c +++ game.c @@ -15,10 +15,12 @@ #include "smallxrm.h" #include "heromesh.h" #include "quarks.h" #include "cursorshapes.h" +static volatile Uint8 timerflag; + static void redraw_game(void) { char buf[32]; SDL_Rect r; int x,y; r.x=r.y=0; @@ -110,24 +112,39 @@ } s=sqlite3_str_finish(m); if(s) SDL_WM_SetCaption(s,s); else SDL_WM_SetCaption("Free Hero Mesh","Free Hero Mesh"); sqlite3_free(s); } + +static Uint32 timer_callback(Uint32 n) { + if(!timerflag) { + static SDL_Event ev={SDL_USEREVENT}; + SDL_PushEvent(&ev); + } + timerflag=1; + return n; +} void run_game(void) { int i; SDL_Event ev; set_caption(); begin_level(level_id); redraw_game(); + timerflag=0; + SDL_SetTimer(10,timer_callback); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_VIDEOEXPOSE: redraw_game(); break; case SDL_QUIT: exit(0); + break; + case SDL_USEREVENT: + //TODO: animation + timerflag=0; break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x