From: parking_turkeys Date: Thu, 16 Jul 2026 20:04:07 +0000 (-0400) Subject: add more animations!! X-Git-Tag: v1.0~40 X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=6be18cb4b6bd2e7cf5a9d1e8de53f8e5f4348d03;p=aichan-platformer.git add more animations!! --- diff --git a/aichan_walk_sheet.png b/aichan_walk_sheet.png new file mode 100644 index 0000000..a57de81 Binary files /dev/null and b/aichan_walk_sheet.png differ diff --git a/game.h b/game.h index ef7e343..3bd1a3d 100644 --- a/game.h +++ b/game.h @@ -10,7 +10,7 @@ #define ZeichnenAnfangen() BeginDrawing() #define ZeichnenAufhören() EndDrawing() -#define SPEED 30 +#define SPEED 40 #define GRAVITY 20 #define FRAMELENGTH 0.1 #define JUMPVELOCITY -130 diff --git a/level.c b/level.c index 61401bf..c3ac34e 100644 --- a/level.c +++ b/level.c @@ -12,6 +12,7 @@ #define CHARADISPLAYWIDTH 140 #define DLGPADDING 5 #define CHARANAMETEXTSIZE 30 +#define DLGTEXTWIDTH SCREENWIDTH - DLGPADDING * 2 - CHARADISPLAYWIDTH int current_dialogue = 0; diff --git a/level_data.h b/level_data.h index 735b58f..1796f38 100644 --- a/level_data.h +++ b/level_data.h @@ -1,5 +1,5 @@ #define STAGECOUNT 3 -#define DIALOGUECOUNT 6 +#define DIALOGUECOUNT 9 #define PLATFORMCOUNT 5 #include "game.h" @@ -8,23 +8,34 @@ struct dialogue dialogues[DIALOGUECOUNT] = { {"Hello!! [press 'H' to advance dialogue]", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, - {"My name is Ai-chan, and i;m the AI of the Hyperion battleship :3", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + {"My name is Ai-chan, and i;m the AI of the Hyperion :3", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, {"(for context thsi is a honkai impact 3 reference... i swear it makes sense", "context", "dialogue-img/aichan-default.png", BLACK}, + {"So there's these girls Rozaliya and Liliya who think they can become the main characters of a game...", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + {"I'm clearly way more awesome than them so I am becoming the main character of a game >:{", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + {"Now we have to find them and prove this!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, {"Please press 'A' and 'D' to move LEFT and RIGHT; advance to the RIGHT side of the screen to finish this level!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + + {"Press 'H' to JUMP", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + + {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN} }; struct platform platforms[PLATFORMCOUNT] = { {{0,320,640,160},GREEN}, + + {{0,320,640,160},GREEN}, {{310, 300, 40, 20}, GREEN}, + + {{0, 320, 640, 160}, GREEN}, {{320, 0, 320, 480}, GREEN} }; struct stage stages[STAGECOUNT] = { - {"Level 0", platforms, 1, dialogues, 4}, - {"Level 1", platforms+1, 2, dialogues+4, 1}, + {"Level 0", platforms, 1, dialogues, 7}, + {"Level 1", platforms+1, 2, dialogues+7, 1}, {"End", platforms+3, 2, dialogues+5, 1} }; diff --git a/main_v2.c b/main_v2.c index 37128f2..e55fe54 100644 --- a/main_v2.c +++ b/main_v2.c @@ -19,6 +19,8 @@ int main(void) SetWindowIcon(LoadImage(ICONPATH)); SetTargetFPS(FPS); + SetTraceLogLevel(LOG_WARNING); + struct character *player = spielersetup(); frozen= 1; //for dialogue @@ -27,7 +29,7 @@ int main(void) if (!frozen) {variables(GetFrameTime(), player);}; ZeichnenAnfangen(); bühnezeichnen(); - spielerzeichnen(); + if (!frozen) {spielerzeichnen();}; ZeichnenAufhören(); } diff --git a/player.c b/player.c index 2ec37f4..e7c4974 100644 --- a/player.c +++ b/player.c @@ -4,12 +4,12 @@ #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 -static struct spritesheet front_sheet; -static struct spritesheet *sheets[1]; +static struct spritesheet front_sheet, walk_sheet; +static struct spritesheet *sheets[2]; -Texture2D front_single; -Texture2D txtr; +static Texture2D front_single; +static Texture2D txtr; static float delta_player; @@ -20,28 +20,37 @@ struct character *spielersetup(void) front_single = LoadTextureFromImage(img); UnloadImage(img); img = LoadImage("aichan-front-sheet.png"); - front_sheet.img = img; front_sheet.width_each = 15; front_sheet.height_each = 18; front_sheet.columns=13; + front_sheet = (struct spritesheet){ImageCopy(img), 15, 18, 13}; + //front_sheet.img = img; front_sheet.width_each = 15; front_sheet.height_each = 18; front_sheet.columns=13; UnloadImage(img); sheets[0] = &front_sheet; txtr = LoadTextureFromImage(front_sheet.img); + + img = LoadImage("aichan_walk_sheet.png"); + walk_sheet = (struct spritesheet){ImageCopy(img), 15, 18, 4}; + UnloadImage(img); + sheets[1] = &walk_sheet; + return &player; } +int drawframe(struct spritesheet *sheet, Rectangle *croprec, int mirror); + int spielerzeichnen(void) { static float time_since_switch = FRAMELENGTH; static Rectangle croprec = {0,0,15,18}; time_since_switch += delta_player; if (time_since_switch >= FRAMELENGTH) { - UnloadTexture(txtr); - Image imgy = LoadImage("aichan-front-sheet.png"); - ImageCrop(&imgy,croprec); - //ImageCrop(&imgy, croprec); - txtr = LoadTextureFromImage(imgy); - UnloadImage(imgy); + if (IsKeyDown(inputs[1])) { + drawframe(sheets[1], &croprec, 0); + } else if (IsKeyDown(inputs[0])) { + drawframe(sheets[1], &croprec, 1); + } else { + drawframe(sheets[0], &croprec, 0); + }; + time_since_switch = 0.0; - if (croprec.x < front_sheet.width_each * (front_sheet.columns - 1)) {croprec.x += front_sheet.width_each;} else {croprec.x = 0;}; - } DrawTexture(txtr, player.rect.x, player.rect.y, WHITE); } @@ -81,6 +90,19 @@ int player_cleanup(void) { UnloadTexture(front_single); UnloadTexture(txtr); - UnloadImage(front_sheet.img); + UnloadImage(sheets[0]->img); return 1; } + +int drawframe(struct spritesheet *s, Rectangle *c, int mirror) +{ + UnloadTexture(txtr); + Image imgy = ImageFromImage(s->img, *c); + if (mirror) {ImageFlipHorizontal(&imgy);}; + //ImageCrop(&imgy,croprec); + //ImageCrop(&imgy, croprec); + txtr = LoadTextureFromImage(imgy); + UnloadImage(imgy); + if (c->x < s->width_each * (s->columns - 1)) {c->x += s->width_each;} else {c->x = 0;}; +} + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..0cfed45 Binary files /dev/null and b/screenshot.png differ