Advertisement
nutter666

c++ rewrite

Feb 6th, 2014
403
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. // horrible rewrite since I don't know C++ syntax
  7.  
  8. getDist(firstObjectX:Number,firstObjectY:Number,secondObjectX:Number,secondObjectY:Number) {
  9.             var distance:Number = Math.sqrt( ( firstObjectX - secondObjectX ) * ( firstObjectX - secondObjectX ) + ( firstObjectY - secondObjectY ) * ( firstObjectY - secondObjectY ) );
  10.             return distance;
  11.         }
  12.  
  13. // example
  14. if(getDist(firstThing,secondThing) <= tooCloseRadius){
  15. firstThing.move();
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement