Python Forum

Full Version: compare and find the nearest element ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello,
I need a little help, I have a list (element has 2 elements(X and Y)), and I need to find, in this list, which element is the nearest of my mouse (we have already X and Y of the mouse).
Can you help me please ?

Also, can you know how can I wrote "move away" for evade if they are bomb in approach ? like " Xbomb - 30px ", can it work ?

PS : I'm french, sorry if I make misstake in my message... Doh
Please show the code you have created so far in code tags.
(Jan-14-2023, 09:54 PM)Yoriz Wrote: [ -> ]Please show the code you have created so far in code tags.
what I must put ?
the entire code ?
Show the minimal amount of code required to show the problem you require help with.
For instance how do you represent a list of x and y coordinates, how is the x and y of the mouse represented.
What is a xbomb in relation to the above and what does 30px represent.
If your problem is "nearest" match to a list of numbers,
you can easily write a small example program to demonstrate the problem .
While doing that, you may find that the python module "bisect"
comes very close to what you want, if I understand your question correctly.
Paul