Last active
April 20, 2020 01:19
-
-
Save DevEarley/1438d16d1ea8c6c0798a2f4557586cf4 to your computer and use it in GitHub Desktop.
"AB" collision of two rectangles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Rectangle = { | |
| x: number, | |
| y: number, | |
| h: number, | |
| w: number | |
| } | |
| function areRectanglesColliding(a: Rectangle, b: Rectangle) { | |
| const i = a.x < (b.x + b.w); | |
| const ii = b.x < (a.x + a.w); | |
| const iii = a.y < (b.y + b.h); | |
| const iv = b.y < (a.y + a.h); | |
| return i && ii && iii && iv; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment