Python Forum
while movinig an object how do i keep it inbounds
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
while movinig an object how do i keep it inbounds
#7
if i add a variable for the image like so this does work, but i still have to manually figure out what positions are the limits and then enter those numbers,
the 680 for x and 326 for y. if my image is 720X400 give or take and the object is 60X60
def move(self,x,y):
       imgx,imgy = canvas.coords(self.id)
       print(imgx,imgy)
       x = max(-imgx, min(x , 680 -imgx ))
       y = max(-imgy, min(y, 326  -imgy ))

       self.x += x
       self.y += y

       canvas.move(self.id, x,y)
Reply


Messages In This Thread
RE: while movinig an object how do i keep it inbounds - by gr3yali3n - Feb-18-2021, 06:35 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020