]> _ Git - aichan-platformer.git/commitdiff
animations but it's broken, readme update
authorparking_turkeys <roya1060wien@gmail.com>
Wed, 15 Jul 2026 13:41:44 +0000 (09:41 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Wed, 15 Jul 2026 13:41:44 +0000 (09:41 -0400)
game.h
level.c
player.c

diff --git a/game.h b/game.h
index 0a9af97..ef7e343 100644 (file)
--- 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 (file)
--- 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
index c3c1845..fbae32e 100644 (file)
--- 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;
 }