ATTENTION: CE PROGRAMME EXIGE TOUTE LA MEMOIRE DE LA CALCULATRICE, ET LE SCRIPT frames.py (voir mes autres scripts) DOIT AUSSI ETRE INSTALLE SOUS PEINE DE DYSFONCTIONNEMENT.
Jeu de labyrithe: Atteignez la coupe pour gagner, en utilisant les touches 4;2;8 et 6 suivies de EXE pour aller à gauche;bas;haut;droite respectivement. Si vous souhaitez modifier le niveau: 0=vide; 1=arbre; 2=eau; 3=terre; 5=coupe (faute de mémoire, il est possible de l’attraper uniquement en venant du haut); tous les multiples de 10=clés d’ID égal au multiple choisi; tous les multiples négatifs de 10=portes d’ID égal au multiple choisi. Noter qu’une porte ne peut être ouverte qu’une fois avec une clé de même ID.
UPDATE: Une version largement améliorée est à présent disponible! Cherchez labyrinth_2 dans scripts de pikube
import kandinsky as kimport random from frames import * x_size=15 y_size=13 #rendered tiles on y\x axis #needs to be odd def fill(a,b,c,d,e): k.fill_rect(a,b,c,d,e) #the idea is to have a maze #moving while you stay stationnary #LETS GO MA BOI #1 for wall, 0 for nothing level=[ [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1], [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,0,0,0,0,1], [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,50,0,0,0,1], [1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,1,0,0,0,0,0,1], [1,0,0,0,0,1,3,3,1,0,0,0,2,2,2,2,0,0,1,3,3,1,1,1,1,1,1,1,0,0,1], [1,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,3,3,3,1,0,0,0,0,1], [1,0,1,2,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,3,3,3,1,0,1,1,1,1], [1,0,1,2,0,0,0,1,1,1,1,1,0,1,1,0,1,1,0,0,0,1,3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,3], [3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3], ] class player(): def __init__(self): self.y=(len(level)-1)/2 self.x=(len(level[0])-1)/2 while 1: self.act() def search(self,u): for cy in range(len(level)): if level[cy].count(u)>0: level[cy][level[cy].index(u)]=0 def find(self,u): if u<0 and u%10==0: self.search(u),self.search(-u) def render(self): #boarders and refresh refresh() #render each case up,left=int(self.y-(y_size-1)/2),int(self.x-(x_size-1)/2) for cux in range(x_size): for cuy in range(y_size): cy=up+cuy cx=left+cux #in the bounds if cy<len(level) and cy>=0 and cx<len(level[0]) and cx>=0: if level[cy][cx]==0: draw_grass(21*cux+2,17*cuy,1) if level[cy][cx]==1: draw_tree(21*cux+2,17*cuy) if level[cy][cx]==2: draw_water(21*cux+2,17*cuy) if level[cy][cx]==3: draw_rock(21*cux+2,17*cuy) if level[cy][cx]==5: draw_trophey(21*cux+2,17*cuy) if level[cy][cx]>0 and level[cy][cx]%10==0: draw_key(21*cux+2,17*cuy,level[cy][cx]) if level[cy][cx]<0 and level[cy][cx]%10==0: draw_wall(21*cux+2,17*cuy,level[cy][cx]) #out of bounds else: draw_rock(21*cux+2,17*cuy) #player draw_player(160-11,111-9) def act(self): #moves self.render() k=input() #collision system if self.y<(len(level)-1) and self.y>0 and self.x>0 and self.x<len(level[0])-1: if k=="2": u=level[int(self.y+1)][int(self.x)] if u==0 or u%10==0 and u>0: self.find(-u) self.y+=1 if u==5: text("vous avez gagne!") if k=="8": u=level[int(self.y-1)][int(self.x)] if u==0 or u%10==0 and u>0: self.find(-u) self.y-=1 if k=="4": u=level[int(self.y)][int(self.x-1)] if u==0 or u%10==0 and u>0: self.find(-u) self.x-=1 if k=="6": u=level[int(self.y)][int(self.x+1)] if u==0 or u%10==0 and u>0: self.x+=1 self.find(-u) p=player()