Labyrinthe est un je qui créer un labyrinthe aléatoire et le but est de se déplacer pour trouver la sortie le plus rapidement (un compteur de seconde est placé en haut à gauche)
le labyrinthe se créer par rapport à la couleur du bleu obtenu sur numworks, le fait qu’il fonctionne sur toute les numworks n’est pas sûr.
pour se déplacer: Flèches directionnelles
BON JEU !
from random import randint from time import monotonic from kandinsky import * from ion import * f=0 while f==0: d,e=0,0 fill_rect(0,0,320,222,'white');fill_rect(10,20,2,190,'blue');fill_rect(10,20,300,2,'blue');fill_rect(310,20,2,192,'blue');fill_rect(10,210,300,2,'blue');fill_rect(12,210,8,2,'white');fill_rect(302,20,8,2,'white') while True: a,b=randint(2,31)*10,randint(2,21)*10 while True: c=randint(0,3) if c==0 and b<200 and get_pixel(a,b+10)!=(0,0,248):fill_rect(a,b,2,12,'blue');b+=10;e=0 elif c==1 and b>20 and get_pixel(a,b-10)!=(0,0,248):fill_rect(a,b,2,-10,'blue');b-=10;e=0 elif c==2 and a<300 and get_pixel(a+10,b)!=(0,0,248):fill_rect(a,b,12,2,'blue');a+=10;e=0 elif c==3 and a>20 and get_pixel(a-10,b)!=(0,0,248):fill_rect(a,b,-10,2,'blue');a-=10;e=0 else: e+=1 if e==1000:d=1 break if d==1:break a,b=13,213 def n():fill_rect(a,b,6,6,'white') def m():fill_rect(a,b,6,6,'red') m();start=monotonic() while True: ct=monotonic();et=ct-start;tc=int(et*100) if tc<100:t="0"+str(tc)[:-2]+"."+str(tc)[-2:];draw_string(str(t),0,0) else:t=str(tc)[:-2]+"."+str(tc)[-2:];draw_string(str(t),0,0) if keydown(KEY_LEFT) and get_pixel(a-2,b)!=(0,0,248) and b<213: n();a-=10;m() while keydown(KEY_LEFT):continue elif keydown(KEY_RIGHT) and get_pixel(a+8,b)!=(0,0,248) and b<213: n();a+=10;m() while keydown(KEY_RIGHT):continue elif keydown(KEY_UP) and get_pixel(a,b-2)!=(0,0,248): n();b-=10;m() while keydown(KEY_UP):continue elif keydown(KEY_DOWN) and get_pixel(a,b+8)!=(0,0,248) and b<200: n();b+=10;m() while keydown(KEY_DOWN):continue if b==13:break fill_rect(0,0,320,222,'black') draw_string("rejouer :",120,60,'yellow','black') draw_string("oui",145,90,'green','black') draw_string("non",145,120,'white','black') draw_string("time: "+str(t),5,200,'yellow','black') while True: if keydown(KEY_UP):draw_string("oui",145,90,'green','black');draw_string("non",145,120,'white','black');f=0 if keydown(KEY_DOWN):draw_string("oui",145,90,'white','black');draw_string("non",145,120,'green','black');f=1 if keydown(KEY_OK): while keydown(KEY_OK):continue break