@DD
that wouldn't be accurate because if disx=1 and disy=1 then the total distance is 2 but that's incorrect. If you have two axis of distance you are creating a triangle, the actual distance is the hypotenuse but you are adding the other two side lengths.
You work out the hypotenuse by using trigonometry: The square of the Hypotenuse is equal to sum of the squares of the other two sides.
Sure everyone's heard that before
DistX# = ABS(sprite x(1) - sprite x(2))
DistY# = ABS(sprite y(1) - sprite y(2))
Dist# = SQRT( (DistX#*DistX#)+(DistY#*DistY#) ) : `Hypotenuse
here's a working example
sprite1x = 320 : sprite1y = 240
sprite2x = 400 : sprite2y = 280
DistX# = ABS(sprite1x - sprite2x)
DistY# = ABS(sprite1y - sprite2y)
Dist# = SQRT( (DistX#*DistX#)+(DistY#*DistY#) )
line sprite1x,sprite1y,sprite2x,sprite1y
line sprite2x,sprite1y,sprite2x,sprite2y
line sprite1x,sprite1y,sprite2x,sprite2y : `hypotenuse
ink rgb(0,255,0),0
circle sprite1x,sprite1y,Dist#
ink rgb(255,255,255),0
circle sprite1x,sprite1y,5
circle sprite2x,sprite2y,5
text sprite1x+10,sprite1y,"Sprite 1"
text sprite2x+10,sprite2y,"Sprite 2"
wait key
WARNING: When a calculation is likely to return a real number, all variables used in the calculation must real numbers or it wont work in DBC.
Your sig was erased by a mod because it's larger than 600x120
I didn't know about that rule and it was 659 x 126!
Isn't that a little OTT? I'm gonna have to re-make it because of 65 pixels!!!