It is beyond anything you have ever experienced or imagined
Circular Collision Detection in JavaScript
Collision detection is the core of many games and simulations. It is therefore important to have a simple and efficient collision detection algorithm.
This algorithm uses circles as the basis for colliding elements.
function collision(c1, c2) { var dx = c1.x - c2.x; var dy = c1.y - c2.y; var dist = c1.radius + c2.radius; return (dx * dx + dy * dy <= dist * dist) }
Envisioning it graphically shows how the inequality relates to the Pythagorean Theorem.

| Print article | This entry was posted by Daniel X Moore on June 6, 2010 at 11:47 am, and is filed under Game Development, Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
