Yoha2 Un bug peut en cacher un autre | A la base, j'avais ça:
Citation :
from graph import *
def move(h, v):
global x, y
x, y = x+h, x+v
if x > 270:
x = 0
if x < 0:
x = 270
if y > 270:
y = 0
if y < 0:
y = 270
can.coords(rond, x, y, x+30, y+30)
x, y = 0, 0
fen= Tk()
fen.title("Le petit bonhomme" )
can=Canvas(fen, bg="grey", height=300, width=300)
rond=can.create_oval(x, y, x+30, y+30, width=2, fill="blue" )
can.bind("z", move(-10, 0))
can.bind("q", move(0, -10))
can.bind("d", move(0, 10))
can.bind("s", move(10, 0))
can.grid(row=0, column=0)
fen.mainloop()
|
je l'ai modifié en ça:
Citation :
from graph import *
def movez(event):
move(-10, 0)
def moveq(event):
move(0, -10)
def moved(event):
move(0, 10)
def moves(event):
move(10, 0)
def move(h, v):
global x, y
x, y = x+h, x+v
if x > 270:
x = 0
if x < 0:
x = 270
if y > 270:
y = 0
if y < 0:
y = 270
can.coords(rond, x, y, x+30, y+30)
x, y = 0, 0
fen= Tk()
fen.title("Le petit bonhomme" )
can=Canvas(fen, bg="grey", height=300, width=300)
rond=can.create_oval(x, y, x+30, y+30, width=2, fill="blue" )
can.bind("z", movez)
can.bind("q", moveq)
can.bind("d", moved)
can.bind("s", moves)
can.grid(row=0, column=0)
fen.mainloop()
|
et ça marche toujours pas. Au fait, si vous trouvez ou ça va pas, vous pourriez m'aider à le faire avec les touches directionnelles ?
MErci d'avance. |