diff options
| author | Colday96 <34099856+Colday96@users.noreply.github.com> | 2019-08-19 12:32:17 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2019-08-19 13:32:17 +0200 |
| commit | 12bcdb977a15a4db933765b3cf4af205a492c8b2 (patch) | |
| tree | 31879fbb107f348a430283c2b3f08f1ff66ddcd5 | |
| parent | 973d32f9a73c921dde2d75a6cc3fa9ee111e3e11 (diff) | |
| download | raylib-12bcdb977a15a4db933765b3cf4af205a492c8b2.tar.gz raylib-12bcdb977a15a4db933765b3cf4af205a492c8b2.zip | |
Update shapes.c for smoother collision detection (#946)
By removing the equal sign, if the 2 rects a right next to each other and not overlapping, there will be no collision detection. This is what a majority of other game libraries do and would make it easier to implement collisions for tile based games.
| -rw-r--r-- | src/shapes.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shapes.c b/src/shapes.c index 6217d2ad..a9fafccc 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -1392,8 +1392,8 @@ bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2) { bool collision = false; - if ((rec1.x <= (rec2.x + rec2.width) && (rec1.x + rec1.width) >= rec2.x) && - (rec1.y <= (rec2.y + rec2.height) && (rec1.y + rec1.height) >= rec2.y)) collision = true; + if ((rec1.x < (rec2.x + rec2.width) && (rec1.x + rec1.width) > rec2.x) && + (rec1.y < (rec2.y + rec2.height) && (rec1.y + rec1.height) > rec2.y)) collision = true; return collision; } |
