Advertisement
nutter666

getDist function

Oct 28th, 2012
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getDist(firstObject:Object,secondObject:Object) {
  2.             var distance:Number = Math.sqrt( ( firstObject.x - secondObject.x ) * ( firstObject.x - secondObject.x ) + ( firstObject.y - secondObject.y ) * ( firstObject.y - secondObject.y ) );
  3.             return distance;
  4.         }
  5.  
  6. // example
  7. if(getDist(firstThing,secondThing) <= tooCloseRadius){
  8. firstThing.move();
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement