From: parking_turkeys Date: Fri, 17 Jul 2026 16:45:11 +0000 (-0400) Subject: improve some art and animation stuff, add stuff that kills you uwu X-Git-Tag: v1.0~34 X-Git-Url: http://git.p-t.hackclub.app/?a=commitdiff_plain;h=ac24de71ed03d752fbf982e13c753f05f137534c;p=aichan-platformer.git improve some art and animation stuff, add stuff that kills you uwu --- diff --git a/game.h b/game.h index 3bd1a3d..3b8eaa5 100644 --- a/game.h +++ b/game.h @@ -18,7 +18,8 @@ #define LEVELS 3 struct character *spielersetup(void); -int next_level(void); +int next_level(struct character *player); +int kill_chara(struct character *player); int bühnezeichnen(void); //i dont think stage works here but it seems better than window int spielerzeichnen(void); @@ -31,6 +32,7 @@ int physics(float delta, struct character *player); int on_floor(struct Rectangle *rect); int in_floor(struct Rectangle *rect); +int is_killed(struct Rectangle *rect); int level_cleanup(void); int player_cleanup(void); @@ -60,6 +62,8 @@ struct stage { int platform_count; struct dialogue *dialogues; int dialogue_count; + struct platform *dangers; + int danger_count; }; struct spritesheet { diff --git a/level.c b/level.c index c3ac34e..fd0664a 100644 --- a/level.c +++ b/level.c @@ -30,6 +30,10 @@ int bühnezeichnen(void) DrawRectangleRec(stages[level].platforms[i].rect, stages[level].platforms[i].colour); }; + for (int i = 0; i < stages[level].danger_count; i++) { + DrawRectangleRec(stages[level].dangers[i].rect, stages[level].dangers[i].colour); + } + if (frozen) { //currently in dialogue drawdialogue(); if (IsKeyPressed(ADVANCEKEY)) { @@ -78,6 +82,15 @@ int on_floor(struct Rectangle *rect) //on floor == no overlap but right next to return 0; }; +int is_killed(struct Rectangle *rect) { + for (int i = 0; i < stages[level].danger_count; i++) { + if (CheckCollisionRecs(*rect, stages[level].dangers[i].rect)) { + return 1; + }; + }; + return 0; +}; + int drawdialogue(void) { struct dialogue *dlg = &(stages[level].dialogues[current_dialogue]); diff --git a/level_data.h b/level_data.h index e605f3a..6a1334d 100644 --- a/level_data.h +++ b/level_data.h @@ -1,25 +1,26 @@ #define STAGECOUNT 3 #define DIALOGUECOUNT 9 #define PLATFORMCOUNT 5 +#define DANGERCOUNT 1 #include "game.h" //icons are 40x40 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 :3", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + {"Hello!! [press 'H' to advance dialogue]", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN}, + {"My name is Ai-chan, and i;m the AI of the Hyperion :3", "Ai-chan", "dialogue-img/aichan-smile.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}, + {"So there's these girls Rozaliya and Liliya who think they can become the main characters of a game...", "Ai-chan", "dialogue-img/aichan-neutral.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-angry.png", GREEN}, + {"Now we have to find them and prove this!!", "Ai-chan", "dialogue-img/aichan-angry.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-smile.png", GREEN}, - {"Press 'H' to JUMP", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}, + {"Press 'H' to JUMP", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN}, - {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN} + {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN} }; struct platform platforms[PLATFORMCOUNT] = { @@ -34,8 +35,12 @@ struct platform platforms[PLATFORMCOUNT] = { {{320, 0, 320, 480}, GREEN} }; +struct platform danger[DANGERCOUNT] = { + {{50,310,7,10}, RED} +}; + struct stage stages[STAGECOUNT] = { - {"Level 0", platforms, 1, dialogues, 7}, - {"Level 1", platforms+1, 2, dialogues+7, 1}, - {"End", platforms+3, 2, dialogues+8, 1} + {"Level 0", platforms, 1, dialogues, 7, danger, 0}, + {"Level 1", platforms+1, 2, dialogues+7, 1, danger, 1}, + {"End", platforms+3, 2, dialogues+8, 1, danger, 0} }; diff --git a/main_v2.c b/main_v2.c index ad06b46..cf2a499 100644 --- a/main_v2.c +++ b/main_v2.c @@ -10,7 +10,7 @@ #include #include // seems useful -int level = 0; +int level = 1; int frozen = 0; int main(void) @@ -48,11 +48,18 @@ int variables(float delta, struct character *player) return 1; // :p } -int next_level(void) +int next_level(struct character *player) { level += 1; //printf("incremented level"); frozen = 1; //printf("set frozen\n"); + player->rect.x = 0; player->rect.y = 300; + return 1; +} + +int kill_chara(struct character *player) +{ + player->rect.x = 0; player->rect.y = 300; return 1; } diff --git a/physics.c b/physics.c index a2e010e..851e304 100644 --- a/physics.c +++ b/physics.c @@ -11,8 +11,7 @@ int physics(float delta, struct character *player) gravity(delta, player); move_player(delta,player); if (player->rect.x > SCREENWIDTH) { - player->rect.x = 15; player->rect.y = 120; - next_level(); + next_level(player); }; return 1; } @@ -48,6 +47,9 @@ int move_player(float d, struct character *p) { p->rect.x += stepx; p->rect.y += stepy; + if (is_killed(&p->rect)) { + kill_chara(p); + }; if (in_floor(&p->rect)) { p->rect.x -= stepx; p->rect.y -= stepy; for (;i < steps_phys; i++) { diff --git a/player.c b/player.c index e7c4974..cf585b8 100644 --- a/player.c +++ b/player.c @@ -2,7 +2,7 @@ #include #include #include "game.h" -struct character player = {{310,220,15,18},{0,0}}; +struct character player = {{0,300,6,18},{0,0}}; int inputs[3] = {KEY_A,KEY_D,KEY_H}; //left, right, jump/advance dialogue static struct spritesheet front_sheet, walk_sheet; @@ -40,19 +40,23 @@ int spielerzeichnen(void) { static float time_since_switch = FRAMELENGTH; static Rectangle croprec = {0,0,15,18}; + static int x_offset = 0; time_since_switch += delta_player; if (time_since_switch >= FRAMELENGTH) { if (IsKeyDown(inputs[1])) { - drawframe(sheets[1], &croprec, 0); + drawframe(sheets[1], &croprec, 0); + x_offset = -9; } else if (IsKeyDown(inputs[0])) { drawframe(sheets[1], &croprec, 1); + x_offset= 0; } else { drawframe(sheets[0], &croprec, 0); + x_offset = -3; }; time_since_switch = 0.0; } - DrawTexture(txtr, player.rect.x, player.rect.y, WHITE); + DrawTexture(txtr, player.rect.x + x_offset, player.rect.y, WHITE); } int spieler_bewegen(float delta) // should actually only change velocity, physics file moves player based on velocity uwu