AAAAA IT ANIMATES
i will probably handle animation with an Animation struct containing an array of frames, with options to set intervals and whether it loops or reverts to another state after the animation is done
This commit is contained in:
parent
304282f5fe
commit
aa95148fc9
2 changed files with 14 additions and 1 deletions
14
slutpet.c
14
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue