Skip to content

Instantly share code, notes, and snippets.

@AlexKardone
Last active July 31, 2019 17:21
Show Gist options
  • Save AlexKardone/abcfea25be6029945d8f3c7d3b3feddb to your computer and use it in GitHub Desktop.
Save AlexKardone/abcfea25be6029945d8f3c7d3b3feddb to your computer and use it in GitHub Desktop.
Check overlap between two rectangles
var checkCollisions = function(rect1, rect2) {
var xOverlap = Math.abs(rect1.x - rect2.x) <= Math.max(rect1.width, rect2.width);
var yOverlap = Math.abs(rect1.y - rect2.y) <= Math.max(rect1.height, rect2.height);
return xOverlap && yOverlap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment