I'm just learning python and I wanted to create a small little game, where I can move an object to the left to the right, up and down...
import tkinter
canvas=tkinter.Canvas(width=800,height=600)
canvas.pack()
canvas.create_text(400,200,text='Starlight',font='Arial 100 bold')
canvas.create_text(400,325,text='Press a button to start the game',font='Arial 20')
a=400
b=500
def start(coordinates):
canvas.delete("all")
canvas.create_rectangle(a-20,b,a+20,b-50)
def moveright(coordinates2):
a=a+100
b=b+0
canvas.delete("all")
canvas.create_rectangle(a-20,b,a+20,b-50)
canvas.bind('<Button-1>',start)
canvas.bind('<Button-3>',start)
canvas.bind_all('<Right>',moveright)
I just programmed the moving right part, however I got a problem, it doesnt sees that a is 400, but if i write it into the def then I can move it just once to the new position, then it stops there.....any solution for this?