[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Finding the distance between 2 objects?



Hi, I often need to find the hoz and vert distance between 2 rects when making a 2D game, I am doing it a pretty lengthy way at the moment, eg...

XDIST = rect1.left - rect2.left
if XDIST < 0: XDIST = -XDIST # Make positive

YDIST = rect1.top - rect2.top
if YDIST < 0: YDIST = -YDIST 

IS there any simply way so say- Here are two numbers, whats the difference. This should always be a positive number.
-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze