diff --git a/dat.h b/dat.h index 6457e27..4254bd2 100644 --- a/dat.h +++ b/dat.h @@ -21,6 +21,7 @@ struct Image { struct State { SDL_Window *win; SDL_Renderer *ren; + Uint64 lastframe; Samply *sam; }; diff --git a/slutpet.c b/slutpet.c index 17b6b7d..883cd73 100644 --- a/slutpet.c +++ b/slutpet.c @@ -47,15 +47,24 @@ SDL_AppResult SDL_AppIterate(void *as) { State *st = as; + SDL_Texture *tx; + Uint64 ms; SDL_SetRenderDrawColor(st->ren, 0, 0, 0, SDL_ALPHA_TRANSPARENT); SDL_RenderClear(st->ren); - if (SDL_RenderTexture(st->ren, st->sam->idle->tex, NULL, NULL) == false) { + ms = SDL_GetTicks(); + if ((ms / 100) % 2) + tx = st->sam->walka->tex; + else + tx = st->sam->walkb->tex; + + if (SDL_RenderTexture(st->ren, tx, NULL, NULL) == false) { fuck("rendertexture fail: %s", SDL_GetError()); return SDL_APP_FAILURE; } SDL_RenderPresent(st->ren); + st->lastframe = SDL_GetTicks(); return SDL_APP_CONTINUE; } @@ -80,6 +89,8 @@ SDL_AppInit(void **as, int argc, char **argv) SDL_SetHint(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, "1"); + st->lastframe = SDL_GetTicks(); + babble("create win+render..."); if (!SDL_CreateWindowAndRenderer("slutpet", 320, 320, SDL_WINDOW_TRANSPARENT | SDL_WINDOW_BORDERLESS @@ -98,5 +109,6 @@ SDL_AppInit(void **as, int argc, char **argv) } babble("hi!!"); + babble("program startup took %llums!", SDL_GetTicks()); return SDL_APP_CONTINUE; }