1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| x1=5
y1=5
x2=45
y2=45
def move_down():
if x1%100 == 5 :
global y1,y2
if y1<400:
y1=y1+50
y2=y2+50
else :
y1=y1
y2=y2
can.coords(Perso,x1,y1,x2,y2)
def move_up():
if x1%100 == 5 :
global y1,y2
if y1>50:
y1=y1-50
y2=y2-50
else :
y1=y1
y2=y2
can.coords(Perso,x1,y1,x2,y2)
def move_left():
if y1%100==5:
global x1,x2
if x1>50:
x1=x1-50
x2=x2-50
else :
x1=x1
x2=x2
can.coords(Perso,x1,y1,x2,y2)
def move_right():
if y1%100==5:
global x1,x2
if x1<700:
x1=x1+50
x2=x2+50
else:
x1=x1
x2=x2
can.coords(Perso,x1,y1,x2,y2)
def blocs():
a=randint(1,15)
b=randint(1,8)
x=a*50
y=b*50
if x != x1:
can.create_rectangle(x,y,x+50,y+50,fill="brown") |
Partager