Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Moving with objects in tkinter
Hi all, can anybody tell me, how to find out if some object is currently located at specific coordinates? Let´s consider object1 at x=100,y=100 and I want to know, if object2 is located somewhere near to this object1, let´s say up to 50px. How to write it and what´s the syntax of this? I already know that I can change coordinates by canvas.coords(object, xy) or change some parameters of that object by canvas.itemconfig(object, parameters). Thanks a lot.
There are several ways to measure the distance between two points in the plane
def distA(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

def distB(x1, y1, x2, y2):
    return ((x1 - x2)**2 + abs(y1 - y2)**2)**0.5

def distC(x1, y1, x2, y2):
    return max(abs(x1 - x2), abs(y1 - y2))
Well but I need to know how to write a coordinates for specific objects. Let´s say object1 is 100,50. How can I write this without specific numbers? Just something like object1_x ?

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Turtle]Need help with moving a square on key press GalaxyCoyote 2 206 May-18-2019, 05:31 PM
Last Post: Yoriz
  moving from os to subprocess Barrowman 10 2,459 Dec-20-2017, 09:08 AM
Last Post: Barrowman
  [PyQt] how to dynamically add objects to pyqt window LavaCreeperKing 1 6,047 Apr-26-2017, 09:15 PM
Last Post: joe_anonimist

Forum Jump:

Users browsing this thread: 1 Guest(s)