Created
February 6, 2011 22:32
-
-
Save ardcore/813784 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
var sth1 = {}, sth2 = {}; | |
sth1.x = 10; // x pos | |
sth1.y = 10; // y pos | |
sth1.r = 10; // radius | |
sth2.x = 15; // x pos | |
sth2.y = 15; // y pos | |
sth2.r = 10; // radius | |
function testCircleCollision(obj1, obj2) { | |
var dist = Math.sqrt( Math.pow(obj2.x - obj1.x, 2) + Math.pow(obj2.y - obj1.y, 2) ); | |
return dist < (obj1.r + obj2.r); | |
} | |
testCircleCollision(sth1, sth2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment