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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| def move_down():
pass
global y1,y2,x1,x2,liste_blocs,newTagdroit,newTagbas,newTaggauche,newTaghaut
if x1%100 == 5 :
if y1<400:
ytest=y1+45
xtest=x1-5
if [xtest,ytest] in liste_blocs:
return
else:
y1=y1+50
y2=y2+50
can.coords(Perso,x1,y1,x2,y2)
if x1==705:
if y1==405:
can.delete(ALL)
can.create_text(225,375,text='Gagné !',font="Arial 50")
son.stop()
can.addtag_enclosed("newTagdroit", x1+45, y1-5, x2+55,y2+5)
can.addtag_enclosed("newTagbas", x1-5, y1+45,x2+5,y2+55)
can.addtag_enclosed("newTaggauche", x1-55, y1-5,x2-45,y2+5)
can.addtag_enclosed("newTaghaut", x1-5, y1-55,x2-45,y2+5)
def move_up():
pass
global y1,y2,x1,x2,liste_blocs,newTagdroit,newTagbas,newTaggauche,newTaghaut
if x1%100 == 5 :
if y1>50:
ytest=y1-55
xtest=x1-5
if [xtest,ytest] in liste_blocs:
return
else:
y1=y1-50
y2=y2-50
can.coords(Perso,x1,y1,x2,y2)
can.addtag_enclosed("newTagdroit", x1+45, y1-5, x2+55,y2+5)
can.addtag_enclosed("newTagbas", x1-5, y1+45,x2+5,y2+55)
can.addtag_enclosed("newTaggauche", x1-55, y1-5,x2-45,y2+5)
can.addtag_enclosed("newTaghaut", x1-5, y1-55,x2-45,y2+5)
def move_left():
pass
global y1,y2,x1,x2,liste_blocs,newTagdroit,newTagbas,newTaggauche,newTaghaut
if y1%100==5:
if x1>50:
ytest=y1-5
xtest=x1-55
if [xtest,ytest] in liste_blocs:
return
else:
x1=x1-50
x2=x2-50
can.coords(Perso,x1,y1,x2,y2)
can.addtag_enclosed("newTagdroit", x1+45, y1-5, x2+55,y2+5)
can.addtag_enclosed("newTagbas", x1-5, y1+45,x2+5,y2+55)
can.addtag_enclosed("newTaggauche", x1-55, y1-5,x2-45,y2+5)
can.addtag_enclosed("newTaghaut", x1-5, y1-55,x2-45,y2+5)
def move_right():
pass
global y1,y2,x1,x2,liste_blocs,newTagdroit,newTagbas,newTaggauche,newTaghaut
if y1%100==5:
if x1<700:
ytest=y1-5
xtest=x1+50-5
if [xtest,ytest] in liste_blocs:
return
else:
x1=x1+50
x2=x2+50
can.coords(Perso,x1,y1,x2,y2)
if x1==705:
if y1==405:
can.delete(ALL)
can.create_text(350,250,text='Gagné !',font="Arial 50")
son.stop()
can.addtag_enclosed("newTagdroit", x1+45, y1-5, x2+55,y2+5)
can.addtag_enclosed("newTagbas", x1-5, y1+45,x2+5,y2+55)
can.addtag_enclosed("newTaggauche", x1-55, y1-5,x2-45,y2+5)
can.addtag_enclosed("newTaghaut", x1-5, y1-55,x2+5,y2-45)
def blocs():
global liste_blocs,obs
a=randint(0,14)
b=randint(0,8)
if (a+b)%2!=0:
if a==0 and b==0:
return False
else:
x=a*50
y=b*50
can.create_rectangle(x,y,x+50,y+50,fill="brown")
liste_blocs.append([x,y]) # on fait une liste des coordonnées des blocs
return True
else:return False
def bloc_destroy():
global y1,y2,x1,x2,liste_blocs,obs
if [x1+45,y1-5] in liste_blocs:
liste_blocs.remove([x1+45,y1-5]) #carré a droite
#can.create_rectangle(x1+45,y1-5,x1+95,y1+45,fill="white")
can.delete("newTagdroit")
if [x1-5,y1+45] in liste_blocs:
liste_blocs.remove([x1-5,y1+45]) #carré en bas
#can.create_rectangle(x1-5,y1+45,x1+45,y1+95,fill="white")
can.delete("newTagbas")
if [x1-55,y1-5] in liste_blocs:
liste_blocs.remove([x1-55,y1-5])#carré a gauche
#can.create_rectangle(x1-55,y1-5,x1-5,y1+45,fill="white")
can.delete("newTaggauche")
if [x1-5,y1-55] in liste_blocs:
liste_blocs.remove([x1-5,y1-55])#carré en haut
#can.create_rectangle(x1-5,y1-55,x1+45,y1-5,fill="white")
can.delete("newTaghaut") |
Partager