This commit is contained in:
cat 2025-06-05 16:38:39 +10:00
parent 0fc07ac95e
commit cf5334fb66
3 changed files with 18 additions and 3 deletions

3
dat.h
View file

@ -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;
};

View file

@ -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;

View file

@ -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,