bonk
This commit is contained in:
parent
0fc07ac95e
commit
cf5334fb66
3 changed files with 18 additions and 3 deletions
3
dat.h
3
dat.h
|
@ -8,6 +8,7 @@ struct Samply {
|
||||||
Image *idle;
|
Image *idle;
|
||||||
Image *walka;
|
Image *walka;
|
||||||
Image *walkb;
|
Image *walkb;
|
||||||
|
Image *error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Image {
|
struct Image {
|
||||||
|
@ -25,7 +26,9 @@ struct State {
|
||||||
SDL_Renderer *ren;
|
SDL_Renderer *ren;
|
||||||
SDL_DisplayID dpy;
|
SDL_DisplayID dpy;
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
|
|
||||||
Uint64 lastframe;
|
Uint64 lastframe;
|
||||||
|
Uint64 frame;
|
||||||
|
|
||||||
Samply *sam;
|
Samply *sam;
|
||||||
};
|
};
|
||||||
|
|
16
samply.c
16
samply.c
|
@ -26,11 +26,11 @@ samply_step(State *st)
|
||||||
x++;
|
x++;
|
||||||
babble("bounds %d %d %d %d", st->bounds.x, st->bounds.y,
|
babble("bounds %d %d %d %d", st->bounds.x, st->bounds.y,
|
||||||
st->bounds.w, st->bounds.h);
|
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 (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;
|
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*");
|
babble("*bonk*");
|
||||||
}
|
}
|
||||||
if (SDL_SetWindowPosition(st->win, x, y) == false)
|
if (SDL_SetWindowPosition(st->win, x, y) == false)
|
||||||
|
@ -53,6 +53,8 @@ put_samply_to_bed(Samply *sam)
|
||||||
free_image(sam->walka);
|
free_image(sam->walka);
|
||||||
babble("free samply walk b!!");
|
babble("free samply walk b!!");
|
||||||
free_image(sam->walkb);
|
free_image(sam->walkb);
|
||||||
|
babble("free samply woozy!!");
|
||||||
|
free_image(sam->error);
|
||||||
babble("good night, samply!!");
|
babble("good night, samply!!");
|
||||||
SDL_free(sam);
|
SDL_free(sam);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +96,14 @@ wake_samply_up(State *st)
|
||||||
return NULL;
|
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;
|
sam->tx = sam->idle;
|
||||||
|
|
||||||
return sam;
|
return sam;
|
||||||
|
|
|
@ -50,6 +50,7 @@ SDL_AppIterate(void *as)
|
||||||
SDL_Texture *tx;
|
SDL_Texture *tx;
|
||||||
Uint64 ms;
|
Uint64 ms;
|
||||||
|
|
||||||
|
st->frame++;
|
||||||
SDL_SetRenderDrawColor(st->ren, 0, 0, 0, SDL_ALPHA_TRANSPARENT);
|
SDL_SetRenderDrawColor(st->ren, 0, 0, 0, SDL_ALPHA_TRANSPARENT);
|
||||||
SDL_RenderClear(st->ren);
|
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");
|
SDL_SetHint(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, "1");
|
||||||
|
|
||||||
st->lastframe = SDL_GetTicks();
|
st->lastframe = SDL_GetTicks();
|
||||||
|
st->frame = 0;
|
||||||
|
|
||||||
babble("create win+render...");
|
babble("create win+render...");
|
||||||
if (!SDL_CreateWindowAndRenderer("slutpet", 320, 320,
|
if (!SDL_CreateWindowAndRenderer("slutpet", 320, 320,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue