From: parking_turkeys Date: Wed, 22 Jul 2026 20:36:59 +0000 (-0400) Subject: failed walljump method (just going to try flipped onfloor... unless this is an issue... X-Git-Tag: v1.0~25 X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=2b4f5e78434969149787d6b729f00ee08d2f96cf;p=aichan-platformer.git failed walljump method (just going to try flipped onfloor... unless this is an issue with the collision detection pushing it 1 px away from the wall?? --- diff --git a/game.h b/game.h index d2bc7e8..a6fe8b8 100644 --- a/game.h +++ b/game.h @@ -32,6 +32,7 @@ int physics(float delta, struct character *player); int on_floor(struct Rectangle *rect); int in_floor(struct Rectangle *rect); +int sliding_wall(struct Rectangle *rect); int is_killed(struct Rectangle *rect); int level_cleanup(void); diff --git a/level.c b/level.c index ac7ca67..1af6efa 100644 --- a/level.c +++ b/level.c @@ -82,6 +82,28 @@ int on_floor(struct Rectangle *rect) //on floor == no overlap but right next to return 0; }; +int sliding_wall(struct Rectangle *rect) +{ + // definition of sliding: not on floor + wall collision rect is >1 high and 1 wide + if (on_floor(rect)) { + return 0; + } else { + for (int i = 0; i < stages[level].platform_count; i++) { + //printf("check slide"); + Rectangle *check = &(stages[level].platforms[i].rect); + if (CheckCollisionRecs(*rect, *check)) { + printf("colliding!!"); + Rectangle overlap = (GetCollisionRec(*rect, *check)); + if ((overlap.height > 1) &&( overlap.width == 1)) { + printf("sliding!!"); + return 1; + } + } + } + }; + 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)) { diff --git a/level_data.h b/level_data.h index 787ebfd..6b84bad 100644 --- a/level_data.h +++ b/level_data.h @@ -1,6 +1,6 @@ -#define STAGECOUNT 4 -#define DIALOGUECOUNT 10 -#define PLATFORMCOUNT 9 +#define STAGECOUNT 5 +#define DIALOGUECOUNT 11 +#define PLATFORMCOUNT 12 #define DANGERCOUNT 5 #include "game.h" @@ -23,6 +23,7 @@ struct dialogue dialogues[DIALOGUECOUNT] = { {"Those red squares are dangerous!! Don't touch them.", "Ai-chan", "dialogue-img/aichan-angry.png", GREEN}, + {"To wall-jump, slide on a wall and press the JUMP key.", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN}, {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN} }; @@ -36,11 +37,17 @@ struct platform platforms[PLATFORMCOUNT] = { {{0, 320, 640, 160}, GREEN}, + {{0,320,80,160},GREEN}, {{100,300,80,10}, GREEN}, {{200,270,60,10}, GREEN}, {{280,240,230,10}, GREEN}, - {{560,420,80,160}, GREEN} + {{560,420,80,160}, GREEN}, + + + {{0,320,640,160},GREEN}, + {{400,80,80,200}, GREEN}, + {{540,100,100,200},GREEN} }; struct platform danger[DANGERCOUNT] = { @@ -57,5 +64,6 @@ struct stage stages[STAGECOUNT] = { {"Movement", platforms, 1, dialogues, 7, danger, 0}, {"Jumping", platforms+1, 2, dialogues+7, 1, danger, 0}, {"Danger", platforms+3, 1, dialogues+8, 1, danger, 4}, - {"(level)", platforms+4, 5, dialogues+8,1,danger+4,1} + {"(level)", platforms+4, 5, dialogues+8,1,danger+4,1}, + {"Wall-jumping", platforms+9, 3,dialogues+9,1,danger,0} }; diff --git a/main_v2.c b/main_v2.c index 0b894ee..25726ad 100644 --- a/main_v2.c +++ b/main_v2.c @@ -10,7 +10,7 @@ #include #include // seems useful -int level = 3; +int level = 4; int frozen = 0; int main(void) diff --git a/player.c b/player.c index cf585b8..70540ae 100644 --- a/player.c +++ b/player.c @@ -72,6 +72,8 @@ int spieler_bewegen(float delta) // should actually only change velocity, physic if (on_floor(&player.rect) && IsKeyDown(inputs[2])) { player.velocity.y = JUMPVELOCITY; //printf("JUMP"); + } else if (IsKeyDown(inputs[2]) && sliding_wall(&player.rect)) { + player.velocity.y = JUMPVELOCITY; }; int direction;