From: parking_turkeys Date: Wed, 15 Jul 2026 13:41:44 +0000 (-0400) Subject: animations but it's broken, readme update X-Git-Tag: horizons~1 X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=82c1cf40311037b0a44bfd00ad84cc6b9d161f46;p=aichan-platformer.git animations but it's broken, readme update --- diff --git a/game.h b/game.h index 0a9af97..ef7e343 100644 --- a/game.h +++ b/game.h @@ -27,6 +27,8 @@ int variables(float delta, struct character *player); int spieler_bewegen(float delta); int physics(float delta, struct character *player); + + int on_floor(struct Rectangle *rect); int in_floor(struct Rectangle *rect); @@ -60,6 +62,13 @@ struct stage { int dialogue_count; }; +struct spritesheet { + Image img; + int width_each; + int height_each; + int columns; +}; + //variables extern int level; diff --git a/level.c b/level.c index 5eca124..fddd191 100644 --- a/level.c +++ b/level.c @@ -30,7 +30,6 @@ int bühnezeichnen(void) }; if (frozen) { //currently in dialogue - printf("d"); drawdialogue(); if (IsKeyPressed(ADVANCEKEY)) { if (++current_dialogue == stages[level].dialogue_count) { //dialogue over diff --git a/player.c b/player.c index c3c1845..fbae32e 100644 --- a/player.c +++ b/player.c @@ -4,30 +4,45 @@ #include "game.h" struct character player = {{310,220,15,18},{0,0}}; int inputs[3] = {KEY_A,KEY_D,KEY_H}; //left, right, jump/advance dialogue -Image front_sheet; +static struct spritesheet front_sheet; + +static struct spritesheet *sheets[1]; + Texture2D front_single; +Texture2D txtr; static float delta_player; + + struct character *spielersetup(void) { Image img = LoadImage("aichan-front.png"); front_single = LoadTextureFromImage(img); UnloadImage(img); - - front_sheet = LoadImage("aichan-front-sheet.png"); - + img = LoadImage("aichan-front-sheet.png"); + struct spritesheet front_sheet = {img, 15, 18, 13}; + UnloadImage(img); + sheets[0] = &front_sheet; + txtr = LoadTextureFromImage(front_sheet.img); return &player; } int spielerzeichnen(void) { - static float time_since_switch; + static float time_since_switch = FRAMELENGTH; + static Rectangle croprec = {0,0,15,18}; time_since_switch += delta_player; if (time_since_switch >= FRAMELENGTH) { - //switch frame drawn - time_since_switch = 0; + UnloadTexture(txtr); + + Image imgy = ImageFromImage((front_sheet.img),croprec); + //ImageCrop(&imgy, croprec); + txtr = LoadTextureFromImage(imgy); + UnloadImage(imgy); + time_since_switch = 0.0; + } - DrawTexture(front_single, player.rect.x, player.rect.y, WHITE); + DrawTexture(txtr, player.rect.x, player.rect.y, WHITE); } int spieler_bewegen(float delta) // should actually only change velocity, physics file moves player based on velocity uwu @@ -64,6 +79,7 @@ int spieler_bewegen(float delta) // should actually only change velocity, physic int player_cleanup(void) { UnloadTexture(front_single); - UnloadImage(front_sheet); + UnloadTexture(txtr); + UnloadImage(front_sheet.img); return 1; }