Last active
August 29, 2015 13:57
-
-
Save ashblue/9887202 to your computer and use it in GitHub Desktop.
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
/** | |
* Detect overlap between two square objects | |
* @param square1 {object} x, y, width, height | |
* @param square2 {object} x, y, width, height | |
* @returns {boolean} | |
*/ | |
function getOverlap(square1, square2) { | |
return square1.x < square2.x + square2.width && | |
square1.x + square1.width > square2.x && | |
square1.y < square2.y + square2.height && | |
square1.y + square1.height > square2.y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment