topical media & game development

talk show tell print

math -- animation 09

math(s) / tutorial(s)

collision(s)



  dx = spriteB.x - spriteA.x;
  dy = spriteB.y - spriteB.y;
  distance = Math.sqrt(dx*dx + dy*dy);
  if (distance < spriteA.radius + spriteB.radius) {
   ...
  }
  

multiple collision(s)



  var max:Number = ...;
  for (var i:uint; i < max; i++) {
    var objectA = objects[i];
    for (var j:uint = i - 1; j < max; j++) { 
        var objectB = objects[j];
        
do detection collision(s)
} }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.