2nd post...
For any 3D game you need to know the distance between two objects, there is this function I made:
FUNCTION Distance3D: x1,y1,z1, x2,y2,z2
RETURN SQR( POW(x2-x1,2) + POW(y2-y1,2) + POW(z2-z1,2) )
ENDFUNCTION
Enjoy!
instead of POW(x2-x1, 2), you might want to use a temp variable, because the POW function is very CPU expensive.
(POW(n, 0.5) is a square root, so POW is at least slower than SQR)
LOCAL dx = x2-x1
RETURN SQR( (dx*dx) + ...
Oh OK I see. So something like this would be faster:
FUNCTION Distance3D: x1,y1,z1, x2,y2,z2
LOCAL a=(x2-x1)
LOCAL b=(y2-y1)
LOCAL c=(z2-z1)
RETURN SQR(a*a+b*b+c*c)
ENDFUNCTION