By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,835 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,835 IT Pros & Developers. It's quick & easy.

Distance between 2 points user chosen.

P: 21
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
Share this question for a faster answer!
Share on Google+

Post your reply

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