From: parking_turkeys Date: Thu, 16 Jul 2026 16:57:20 +0000 (-0400) Subject: fix bug with going into walls X-Git-Tag: v1.0~41 X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=67254ed31df689899f0ff23a47ae2307b7286a61;p=aichan-platformer.git fix bug with going into walls --- diff --git a/level.c b/level.c index fddd191..61401bf 100644 --- a/level.c +++ b/level.c @@ -45,7 +45,11 @@ int bühnezeichnen(void) int in_floor(struct Rectangle *rect) { for (int i = 0; i < stages[level].platform_count; i++) { - if (CheckCollisionRecs(*rect, stages[level].platforms[i].rect)) { return 1; }; + if (CheckCollisionRecs(*rect, stages[level].platforms[i].rect)) { + if (!(stages[level].platforms[i].rect.y == rect->y + rect->height)) {// this would mean rect is just sitting on top of it + return 1; //we dont want it to return 1 if they're just on the floor + }; + }; }; return 0; } diff --git a/physics.c b/physics.c index 4b61882..a2e010e 100644 --- a/physics.c +++ b/physics.c @@ -48,7 +48,7 @@ int move_player(float d, struct character *p) { p->rect.x += stepx; p->rect.y += stepy; - if (!on_floor(&p->rect) && in_floor(&p->rect)) { + if (in_floor(&p->rect)) { p->rect.x -= stepx; p->rect.y -= stepy; for (;i < steps_phys; i++) { if (stepx > 0) {p->rect.x += 1; if (in_floor(&p->rect)) { p->rect.x-=1; };} else if (stepx < 0) {p->rect.x -= 1; if (in_floor(&p->rect)) { p->rect.x+=1; };};