]> _ Git - aichan-platformer.git/commitdiff
fix bug with going into walls
authorparking_turkeys <roya1060wien@gmail.com>
Thu, 16 Jul 2026 16:57:20 +0000 (12:57 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Thu, 16 Jul 2026 16:57:20 +0000 (12:57 -0400)
level.c
physics.c

diff --git a/level.c b/level.c
index fddd191..61401bf 100644 (file)
--- 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;
 }
index 4b61882..a2e010e 100644 (file)
--- 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; };};