From 6a826d4b377a58f68038dbe4f25b8ee2767d9c19 Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 26 May 2025 15:11:05 +1000 Subject: [PATCH 1/3] square window size (samply imgs are square) --- samply.c | 11 +++++------ slutpet.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/samply.c b/samply.c index 16ce3b1..a82bd31 100644 --- a/samply.c +++ b/samply.c @@ -13,10 +13,9 @@ put_samply_to_bed(Samply *sam) free_image(sam->walka); babble("free samply walk b!!"); free_image(sam->walkb); + babble("good night, samply!!"); + SDL_free(sam); } - - babble("good night, samply!!"); - SDL_free(sam); } Samply * @@ -34,7 +33,7 @@ wake_samply_up(SDL_Renderer *ren) babble("stand samply up!!"); sam->idle = load_image(ren, "samply/Samply.png"); if (!sam->idle) { - fuck("samply would rather stay in bed. too bad! %s", SDL_GetError()); + fuck("samply would rather stay in bed. too bad!"); put_samply_to_bed(sam); return NULL; } @@ -42,7 +41,7 @@ wake_samply_up(SDL_Renderer *ren) babble("samply walk! part 1!!"); sam->walka = load_image(ren, "samply/Samply_Walk1.png"); if (!sam->walka) { - fuck("samply would rather stay in bed. too bad! %s", SDL_GetError()); + fuck("samply would rather stay in bed. too bad!"); put_samply_to_bed(sam); return NULL; } @@ -50,7 +49,7 @@ wake_samply_up(SDL_Renderer *ren) babble("samply walk! part 2!!"); sam->walkb = load_image(ren, "samply/Samply_Walk2.png"); if (!sam->walkb) { - fuck("samply would rather stay in bed. too bad! %s", SDL_GetError()); + fuck("samply would rather stay in bed. too bad!"); put_samply_to_bed(sam); return NULL; } diff --git a/slutpet.c b/slutpet.c index 69ae2b2..17b6b7d 100644 --- a/slutpet.c +++ b/slutpet.c @@ -81,7 +81,7 @@ SDL_AppInit(void **as, int argc, char **argv) SDL_SetHint(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, "1"); babble("create win+render..."); - if (!SDL_CreateWindowAndRenderer("slutpet", 320, 240, + if (!SDL_CreateWindowAndRenderer("slutpet", 320, 320, SDL_WINDOW_TRANSPARENT | SDL_WINDOW_BORDERLESS | SDL_WINDOW_NOT_FOCUSABLE | SDL_WINDOW_ALWAYS_ON_TOP, From 304282f5fe45cfeb9af6ca595f77c17ca8f2d59a Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 26 May 2025 15:28:08 +1000 Subject: [PATCH 2/3] file info to readme --- readme | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/readme b/readme index 09f31cc..26f7cf5 100644 --- a/readme +++ b/readme @@ -8,3 +8,12 @@ i want people to be able to create their own pets without having to figure out how to recompile. run it with `SDL_LOGGING=app=debug ./slutpet` for verbose logging + +file layout: + +dat.h - data structure header +fns.h - functions and macros header + +slutpet.c - sdl init and close +img.c - loading images +samply.c - pet Samply From aa95148fc985041a4abb1f2ee403520e6a34e7c4 Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 26 May 2025 15:39:16 +1000 Subject: [PATCH 3/3] 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 --- dat.h | 1 + slutpet.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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; }