from ion import keydown from kandinsky import * from random import randint from time import sleep liste_cartes = 0 def sol_grotte(x,y): #is 1 fill_rect(x*18,1+y*18,15,15,"#784212") def herbe(x,y): #is 2 fill_rect(x*18,1+y*18,15,15,"#609B41") def rocher_dehors(x,y): #is 3 fill_rect(x*18,1+y*18,15,15,"#424949") def rocher_grotte(x,y):#is 4 fill_rect(x*18,1+y*18,15,15,"#641E16") def eau_dehors(x,y):#is 5 fill_rect(x*18,1+y*18,15,15,"#0000FF") def eau_grotte(x,y):#is 6 fill_rect(x*18,1+y*18,15,15,"#403AAF") matrice_x =[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] matrice_y =[0,1,2,3,4,5,6,7,8,9,10] corrdone = [2,2] coo_carte1 =[] coo_carte2 =[] coo_carte3 =[] coo_carte4 =[] coo_carte5 =[] def position_carte(tab): global coo_carte1, coo_carte2, coo_carte3,coo_carte4,coo_carte5 while coo_carte1 == []: a = randint(15,16) b = randint(1,4) if tab[b][a] != 0: coo_carte1 = [b,a] while coo_carte2 == []: a = randint(3,12) b = randint(1,4) if tab[b][a] != 0: coo_carte2 = [b,a] while coo_carte3 == []: a = randint(1,16) b = randint(6,9) if tab[b][a] != 0: coo_carte3 = [b,a] while coo_carte4 == []: a = randint(3,12) b = randint(1,4) if tab[b][a] != 0: coo_carte4 = [b,a] while coo_carte5 == []: a = randint(1,16) b = randint(6,9) if tab[b][a] != 0: coo_carte5 = [b,a] print(coo_carte1) print(coo_carte2) print(coo_carte3) print(coo_carte4) print(coo_carte5) def font_ecran_generer(tab): for i in range(11): for v in range(18): if tab[i][v] == 1: sol_grotte(matrice_x[v],matrice_y[i]) elif tab[i][v] == 2: herbe(matrice_x[v],matrice_y[i]) elif tab[i][v] == 3: rocher_dehors(matrice_x[v],matrice_y[i]) elif tab[i][v] == 4: rocher_grotte(matrice_x[v],matrice_y[i]) elif tab[i][v] == 5: eau_dehors(matrice_x[v],matrice_y[i]) elif tab[i][v] == 6: eau_grotte(matrice_x[v],matrice_y[i]) tipe_zone = 2 def joeur(tab,tipe_zone): # 2 == sol and 5 == eau and 1 == solgro type_zone(corrdone) if tipe_zone == 2: fill_rect(tab[0]*18,1+tab[1]*18,15,15,"#C70039") elif tipe_zone == 5: fill_rect(tab[0]*18,1+tab[1]*18,15,15, "#222222") elif tipe_zone == 1: fill_rect(tab[0]*18,1+tab[1]*18,15,15, "#6C3483") def type_zone(tab): global tipe_zone if carte_mouv[tab[1]][tab[0]] == 2: tipe_zone = 2 if carte_mouv[tab[1]][tab[0]] == 5: tipe_zone = 5 if carte_mouv[tab[1]][tab[0]] == 1: tipe_zone = 1 carte_appa = [[3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4], [3,2,2,2,2,2,2,2,2,2,2,2,2,4,1,1,1,4], [3,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,4], [3,2,2,2,2,2,2,2,2,2,2,2,2,4,1,1,1,4], [3,2,2,2,2,2,2,2,2,2,2,2,2,4,1,1,1,4], [3,3,3,5,5,3,3,3,3,3,3,3,3,4,4,1,4,4], [3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3], [3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3], [3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3], [3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3], [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]] carte_mouv=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,2,2,2,2,2,2,2,2,2,2,2,2,0,1,1,1,0], [0,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,0], [0,2,2,2,2,2,2,2,2,2,2,2,2,0,1,1,1,0], [0,2,2,2,2,2,2,2,2,2,2,2,2,0,1,1,1,0], [0,0,0,5,5,0,0,0,0,0,0,0,0,0,0,1,0,0], [0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0], [0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0], [0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0], [0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] def mouvement_gauche(): if keydown(0) : if carte_mouv[corrdone[1]][corrdone[0]-1] != 0: corrdone[0] = corrdone[0] -1 font_ecran_generer(carte_appa) joeur(corrdone,tipe_zone) type_zone(corrdone) def mouvement_droite(): if keydown(3): if carte_mouv[corrdone[1]][corrdone[0]+1] != 0: corrdone[0] = corrdone[0] +1 font_ecran_generer(carte_appa) joeur(corrdone,tipe_zone) type_zone(corrdone) def mouvement_haut(): if keydown(1) : if carte_mouv[corrdone[1]-1][corrdone[0]] != 0: corrdone[1] = corrdone[1] -1 font_ecran_generer(carte_appa) joeur(corrdone,tipe_zone) type_zone(corrdone) def mouvement_bas(): if keydown(2) : if carte_mouv[corrdone[1]+1][corrdone[0]] != 0: corrdone[1] = corrdone[1] +1 font_ecran_generer(carte_appa) joeur(corrdone,tipe_zone) type_zone(corrdone) joeur(corrdone,tipe_zone) def toucher_de_carte(): global corrdone,coo_carte1,coo_carte2,coo_carte3,coo_carte4,coo_carte5,liste_cartes if coo_carte1[0] == corrdone[1] and coo_carte1[1] == corrdone[0]: fill_rect(204,202,16,16,"#FF0000") coo_carte1 = [-2,-2] liste_cartes +=1 print("liste_cartes",liste_cartes) if coo_carte2[0] == corrdone[1] and coo_carte2[1] == corrdone[0]: fill_rect(225,202,16,16,"#FFFF00") coo_carte2 = [-20,-20] liste_cartes +=1 print("liste_cartes",liste_cartes) if coo_carte3[0] == corrdone[1] and coo_carte3[1] == corrdone[0]: fill_rect(246,202,16,16,"#00FFFF") coo_carte3 = [-20,-20] liste_cartes +=1 print("liste_cartes",liste_cartes) if coo_carte4[0] == corrdone[1] and coo_carte4[1] == corrdone[0]: fill_rect(267,202,16,16,"#FF00FF") coo_carte4 = [-20,-20] liste_cartes +=1 print("liste_cartes",liste_cartes) if coo_carte5[0] == corrdone[1] and coo_carte5[1] == corrdone[0]: fill_rect(288,202,16,16,"#00FFFF") coo_carte5 = [-20,-20] liste_cartes +=1 print("liste_cartes",liste_cartes) def mouvement2(matrice_j): global corrdone,zone # Déplacement gauche if carte_mouv[corrdone[1]][corrdone[0]] != 0: toucher_de_carte() mouvement_gauche() mouvement_droite() mouvement_haut() mouvement_bas() def genere_carte(): global coo_carte1,coo_carte2,coo_carte3,coo_carte4,coo_carte5 fill_rect(coo_carte1[1]*18,1+coo_carte1[0]*18,15,15, "#FF0000") fill_rect(coo_carte2[1]*18,1+coo_carte2[0]*18,15,15, "#FFFF00") fill_rect(coo_carte3[1]*18,1+coo_carte3[0]*18,15,15, "#00FFFF") fill_rect(coo_carte4[1]*18,1+coo_carte4[0]*18,15,15, "#FF00FF") fill_rect(coo_carte5[1]*18,1+coo_carte5[0]*18,15,15, "#00FFFF") def intro(): trolle = 0 txt1 = "FIND THE RUNE" text_herbe = "herbe :" text_sol = "sol des grottes :" text_grotte = "mur des grottes :" text_roche = "mur en roche :" fill_rect(0,0,360,222,"#000000") for y in range(40): for x in range(60): fill_rect(x*6,y*6,6,6,(randint(0,254),randint(0,10),randint(0,10))) draw_string(txt1, 20+(len(txt1)*10)//2,20,"#FFFFFF","#000000") draw_string(text_herbe,50,70,"#FFFFFF","#000000") fill_rect(220,70,18,18,"#784212") draw_string(text_roche, 50,100,"#FFFFFF","#000000") fill_rect(220,100,18,18,"#609B41") draw_string(text_sol,50,130,"#FFFFFF","#000000") fill_rect(220,130,18,18,"#641E16") draw_string(text_grotte, 50,160,"#FFFFFF","#000000") fill_rect(220,160,18,18,"#0000FF") draw_string("presse fleche du haut ", 50,200,"#FFFFFF","#000000") while trolle ==0: if keydown(1): trolle +=1 jeu() def jeu(): fill_rect(0,0,320,222,"#000000") font_ecran_generer(carte_appa) position_carte(carte_appa) txt = "Carte du Joueur:" draw_string(txt, 42, 200,"#FFFFFF","#000000") fill_rect(202,200,20,20,"#FFFFFF") fill_rect(223,200,20,20,"#FFFFFF") fill_rect(244,200,20,20,"#FFFFFF") fill_rect(265,200,20,20,"#FFFFFF") fill_rect(286,200,20,20,"#FFFFFF") while liste_cartes !=5: joeur(corrdone,tipe_zone) toucher_de_carte() genere_carte() mouvement2(carte_mouv) sleep(0.1) finn() def finn(): #fill_rect(0,0,360,222,"#000000") text = "FIN DU JEUX" ttt = "tu as trouvé les runes" tm = "merci d'avoir jouer <3" for y in range(40): for x in range(60): fill_rect(x*6,y*6,6,6,(randint(0,30),randint(0,10),randint(0,254))) sleep(0.0001) draw_string(text, 50+(len(text)*10)//2,18,"#FFFFFF","#000000") draw_string(ttt,55,60,"#FFFFFF","#000000") draw_string("la gloire te tent la mains",30,100,"#FFFFFF","#000000") draw_string(tm,50,198,"#FFFFFF","#000000") intro()