• Advertisement
Sign in to follow this  

Bounding Circle collision detection: KineticJS/HTML5 Tutorial

This topic is 1640 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

This tutorial explains the mathematics behind collision detection using bounding circle method. Source code and online demo is available with the tutorial.

 

Bounding Circle collision detection: KineticJS/HTML5 Tutorial

 

Just a suggestion: get rid of the sqrt operation. It is slow and unnecessary. The same test can be expressed as,

var sum_radii = sprite1Radius + sprite2Radius;
var sum_radii_sqr = sum_radii * sum_radii;

var dist_sqr = (distanceX * distanceX) + (distanceY * distanceY);

return dist_sqr <= sum_radii_sqr

-Josh

Edited by jjd

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement