Created
April 22, 2016 00:49
-
-
Save sax1johno/63079f2bea08b60cb712d49962a5feed to your computer and use it in GitHub Desktop.
This file contains 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
this.collidesWith = function(otherObject) { | |
var width = 2*this.radius; | |
var height = 2*this.radius; | |
var translatedX = this.x - radius; | |
var translatedY = this.y - radius; | |
if (translatedX < otherObject.x + otherObject.width && | |
translatedX + width > otherObject.x && | |
translatedY < otherObject.y + otherObject.height && | |
height + translatedY > otherObject.y) { | |
// collision detected! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment