View difference between Paste ID: S4ayjujE and 1044vwVH
SHOW: | | - or go back to the newest paste.
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
}