diff options
| author | Ray <raysan5@gmail.com> | 2016-03-16 17:50:51 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2016-03-16 17:50:51 +0100 |
| commit | ee52b13ae63f098c4e26a9812b2088f80fcbe7cc (patch) | |
| tree | 915d7179a328e3d06b3fe00a18072ec4a46afba7 /src | |
| parent | d0e26247f4e4edd4492611dc52cc964bbafefe27 (diff) | |
| download | raylib-ee52b13ae63f098c4e26a9812b2088f80fcbe7cc.tar.gz raylib-ee52b13ae63f098c4e26a9812b2088f80fcbe7cc.zip | |
Corrected bug on GetCollisionRec()
Diffstat (limited to 'src')
| -rw-r--r-- | src/shapes.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/shapes.c b/src/shapes.c index 51730a05..46095d11 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -429,9 +429,24 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2) retRec.height = rec2.height - dyy; } } - - if (retRec.width >= rec2.width) retRec.width = rec2.width; - if (retRec.height >= rec2.height) retRec.height = rec2.height; + + if (rec1.width > rec2.width) + { + if (retRec.width >= rec2.width) retRec.width = rec2.width; + } + else + { + if (retRec.width >= rec1.width) retRec.width = rec1.width; + } + + if (rec1.height > rec2.height) + { + if (retRec.height >= rec2.height) retRec.height = rec2.height; + } + else + { + if (retRec.height >= rec1.height) retRec.height = rec1.height; + } } return retRec; |
