Fix off-by-one error in CheckCollisionPointRec

Checking `<= x + w` causes off-by-one error where `CheckCollisionPointRec` will return true at the same time for two rectangles rendered right next to each, but which don't overlap (e.g. when making a 2D tile editor). This is clearly not what was intended.
This commit is contained in:
Dan Bechard 2023-04-21 17:36:05 -04:00 committed by GitHub
parent 535680668b
commit 7e723b8dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1601,7 +1601,7 @@ bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
{
bool collision = false;
if ((point.x >= rec.x) && (point.x <= (rec.x + rec.width)) && (point.y >= rec.y) && (point.y <= (rec.y + rec.height))) collision = true;
if ((point.x >= rec.x) && (point.x < (rec.x + rec.width)) && (point.y >= rec.y) && (point.y < (rec.y + rec.height))) collision = true;
return collision;
}