From cf5334fb66bc880685bcb1a4da3e97b777d8879c Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 5 Jun 2025 16:38:39 +1000 Subject: [PATCH] bonk --- dat.h | 3 +++ samply.c | 16 +++++++++++++--- slutpet.c | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dat.h b/dat.h index 89a4580..81eb805 100644 --- a/dat.h +++ b/dat.h @@ -8,6 +8,7 @@ struct Samply { Image *idle; Image *walka; Image *walkb; + Image *error; }; struct Image { @@ -25,7 +26,9 @@ struct State { SDL_Renderer *ren; SDL_DisplayID dpy; SDL_Rect bounds; + Uint64 lastframe; + Uint64 frame; Samply *sam; }; diff --git a/samply.c b/samply.c index 7731785..152f162 100644 --- a/samply.c +++ b/samply.c @@ -26,11 +26,11 @@ samply_step(State *st) x++; babble("bounds %d %d %d %d", st->bounds.x, st->bounds.y, st->bounds.w, st->bounds.h); - babble("img %d %d %d %d", x, y, st->sam->tx->w, st->sam->tx->h); + babble("img %d %d %d %d", x, y, st->sam->tx->w / 4, st->sam->tx->h); // if (in_bounds(st->sam->tx, x, y, &st->bounds) == false) { - if (st->bounds.w - st->sam->tx->w < x) { + if (st->bounds.w - st->sam->tx->w / 4 < x) { st->sam->tx = st->sam->idle; - x = st->bounds.w - st->sam->tx->w; + x = st->bounds.w - st->sam->tx->w / 4; babble("*bonk*"); } if (SDL_SetWindowPosition(st->win, x, y) == false) @@ -53,6 +53,8 @@ put_samply_to_bed(Samply *sam) free_image(sam->walka); babble("free samply walk b!!"); free_image(sam->walkb); + babble("free samply woozy!!"); + free_image(sam->error); babble("good night, samply!!"); SDL_free(sam); } @@ -94,6 +96,14 @@ wake_samply_up(State *st) return NULL; } + babble("samply woozy!!"); + sam->error = load_image(st->ren, "samply/SamplyERROR.png"); + if (!sam->error) { + fuck("samply would rather stay in bed. too bad!"); + put_samply_to_bed(sam); + return NULL; + } + sam->tx = sam->idle; return sam; diff --git a/slutpet.c b/slutpet.c index a735780..cfce2da 100644 --- a/slutpet.c +++ b/slutpet.c @@ -50,6 +50,7 @@ SDL_AppIterate(void *as) SDL_Texture *tx; Uint64 ms; + st->frame++; SDL_SetRenderDrawColor(st->ren, 0, 0, 0, SDL_ALPHA_TRANSPARENT); SDL_RenderClear(st->ren); @@ -84,6 +85,7 @@ SDL_AppInit(void **as, int argc, char **argv) SDL_SetHint(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, "1"); st->lastframe = SDL_GetTicks(); + st->frame = 0; babble("create win+render..."); if (!SDL_CreateWindowAndRenderer("slutpet", 320, 320,