ive been pulling out my hair trying to figure out how to get this to work correctly, i dont fully understand why i got this to work. could someone explain this to me, i have been messing around with this for a few days now.. the xv and yv are my constants i was fighting with the class variables so i just set those.
and that is i think on of the keys to my issue.. but i have tried many ways to get this image to move, and i just landed on this..
is the event.symkey needing to be replaced with a while loop of some kind?
and that is i think on of the keys to my issue.. but i have tried many ways to get this image to move, and i just landed on this..
is the event.symkey needing to be replaced with a while loop of some kind?
from tkinter import * from PIL import ImageTk,Image r=Tk() c1 =Canvas(r,height=400,width=720) c1.pack() xv = 1 xy = 1 class ship(): def __init__(self, x=0,y=0): self.img = PhotoImage(file="./8bitship.png") self.id = c1.create_image(0,0,anchor=NW,image=self.img) self.x = x self.y = y def move(self,x,y): c1.move(self.id, x, y) def right(self): c1.move(1,0) def key(self,event): #r.bind("<Right>",right) #r.bind("Right", lambda x: s.move(x = 5,y=0)) if event.symkey == 'Right': self.xv =1 r.bind("<Right>", lambda x: s.move(x=5,y=0)) s = ship(c1) #r.bind("<Right>",lambda x: s.move(x = 5,y = 0 )) #r.bind("<Right>",right) r.mainloop()