#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
int player_cleanup(void)
{
UnloadTexture(front_single);
- UnloadImage(front_sheet);
+ UnloadTexture(txtr);
+ UnloadImage(front_sheet.img);
return 1;
}