I want ot move a defined object in canvas. I know there's a command that moves an object(.move) hovewer it only works on individual items. So how could I move a whole defined object made up of rectangles? Like the one in the example? Because I need to move hundreds of little objects as one.
x=400
y=400
def player(x,y):
canvas.create_rectangle(x,y,x+50,y+50,fill='black')
canvas.create_rectangle(x,y+50,x+150,y+150,fill='red')
def moveright(coordinates2):
global x
global y
x=x+200
y=y+0
player(x,y)
def moveleft(coordinates3):
global x
global y
x=x-200
y=y+0
player(x,y)
def moveup(coordinates4):
global x
global y
x=x+0
y=y-150
player(x,y)
def moveright(coordinates5):
global x
global y
x=x+0
y=y+150
player(x,y)
canvas.bind_all('<Right>',moveright)
canvas.bind_all('<Left>',moveleft)
canvas.bind_all('<Up>',moveup)
canvas.bind_all('<Down>',movedown)