469,602 Members | 1,726 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Distance between 2 points user chosen.

Hi everyone. XP Service pack 2, english, python, I am just wondering how i could go about doing this. I am using pygame to draw 25 objects on the screen and they each are assigned a letter of the alphabet A-Y for the function that loads the image. They also have each have a value A1-Y1 for their starting locations. I already have my collision detection written for when the mouse is clicked on one of these objects so thats not a problem. I then want the user to be able to click on two of these objects and have the program find the distance between the two top left pixels of the two objects. The only way i would know of doing this would be through brute force coding using IF statements for every possible combo and finding the distances by manually puting in the A1-Y1 corresponding value for each object and then using the distance formula ( modified for use by a computer oriented with 0,0 in top left) of square root of- {(X2-X1)^2+(Y1-Y2)^2}. I know their is a better way to do this i just dont know how. IF anyone could help it would be much appreciated. Thanx
Jun 28 '08 #1
0 1297

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

20 posts views Thread by Xenophobe | last post: by
4 posts views Thread by DellaCroce | last post: by
3 posts views Thread by byteschreck | last post: by
8 posts views Thread by giloosh | last post: by
10 posts views Thread by Alan Johnson | last post: by
9 posts views Thread by nottheartistinquestion | last post: by
reply views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.