from math import * from random import * from kandinsky import * from ion import * from time import * colors=[(255,)*3,(0,200,255),(0,0,255),(0,0,255)] dos_carte="000022222222222200000022111111111111220002111333333333311120021331111111111331202113111111111111311221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122131111111111111131221311111111111111312213111111111111113122113111111111111311202133111111111133120021113333333333111200022111111111111220000002222222222220000" _carte2="000022222200000022111111220002111333311120021331111331202113111111311221311111111312213111111113122131111111131221311111111312213111111113122131111111131221311111111312213111111113122131111111131221311111111312213111111113122131111111131221311111111312213111111113122131111111131221311111111312213111111113122131111111131221311111111312213111111113122113111111311202133111133120021113333111200022111111220000002222220000" liste=[9,5,8,3,4,2,1,6,7,7,4,2,8,5,6,3,1,9] memo=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] truc=True while truc: a,d=0,0 for i in memo: b=randint(0,17) if liste[b]!=0 and memo[a]==0: memo[a]=liste[b] liste[b]=0 if i==0:d+=1 a+=1 if d==0:truc=False etat_carte=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] n=2 def memory(list): c=0 for a in range(9,213,68): for b in range(16,304,48): if list[c]==1: Carte(dos_carte,b+4,a+4,n,20,30,[(255,)*3,(0,200,255),(0,0,255),(0,0,255)]) c+=1 def objects(x,y,t,n): if n==1:fill_rect(x,y,16*t,16*t,(255,0,0)) if n==2:fill_rect(x,y,16*t,16*t,(0,0,255)) if n==3:fill_rect(x,y,16*t,16*t,(255,255,0)) if n==4:fill_rect(x,y,16*t,16*t,(255,0,255)) if n==5:fill_rect(x,y+(4*t),16*t,8*2,(0,255,0)) if n==6:fill_rect(x,y+(4*t),16*t,8*2,(255,180,0)) if n==7:fill_rect(x,y+(4*t),16*t,8*2,(0,)*3) if n==8:fill_rect(x,y+(4*t),16*t,8*2,(180,)*3) if n==9:fill_rect(x,y,16*t,16*t,(0,255,255)) def Carte(C,x,y,t,tx,ty,colors): for b in range(0,ty): for c in range(0,tx): fill_rect(x+(c*t),y+(b*t),t,t,colors[int(C[(b*tx)+c])]) def animation1(x,y,n): fill_rect(x,y,20*n,30*n,(255,)*3) Carte(dos_carte,x,y,n,20,30,[(255,)*3,(0,200,255),(0,0,255),(0,0,255)]) sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(_carte2,x+(3*n),y,n,14,30,[(255,)*3,(0,200,255),(0,0,255),(0,0,255)]) sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(_carte2,x+(3*n),y,n,14,30,[(255,)*3,(255,)*3,(0,0,255),(255,)*3]) sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(dos_carte,x,y,n,20,30,[(255,)*3,(255,)*3,(0,0,255),(255,)*3]) def animation2(x,y,n): sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(dos_carte,x,y,n,20,30,[(255,)*3,(255,)*3,(0,0,255),(255,)*3]) sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(_carte2,x+(3*n),y,n,14,30,[(255,)*3,(255,)*3,(0,0,255),(255,)*3]) sleep(0.1) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(_carte2,x+(3*n),y,n,14,30,[(255,)*3,(0,200,255),(0,0,255),(0,0,255)]) fill_rect(x,y,20*n,30*n,(255,)*3) Carte(dos_carte,x,y,n,20,30,[(255,)*3,(0,200,255),(0,0,255),(0,0,255)]) sleep(0.1) def selecteur(x,y,c): fill_rect(x-4,y-4,10,3,c) fill_rect(x-4,y-4,3,10,c) fill_rect(x+44,y-4,-10,3,c) fill_rect(x+44,y-4,-3,10,c) fill_rect(x-4,y+64,10,-3,c) fill_rect(x-4,y+64,3,-10,c) fill_rect(x+44,y+64,-10,-3,c) fill_rect(x+44,y+64,-3,-10,c) _x=20 _y=13 _n=0 n_carte=0 memory(etat_carte) Won=False n_coup=0 t=monotonic() Pressed=False while not Won: if keydown(KEY_LEFT) and _x>20: selecteur(_x,_y,(255,)*3) _x-=48;_n-=1 selecteur(_x,_y,(0,200,255)) Pressed=True if keydown(KEY_RIGHT) and _x<260: selecteur(_x,_y,(255,)*3) _x+=48;_n+=1 selecteur(_x,_y,(0,200,255)) Pressed=True if keydown(KEY_UP) and _y>13: selecteur(_x,_y,(255,)*3) _y-=68;_n-=6 selecteur(_x,_y,(0,200,255)) Pressed=True if keydown(KEY_DOWN)and _y<149: selecteur(_x,_y,(255,)*3) _y+=68;_n+=6 selecteur(_x,_y,(0,200,255)) Pressed=True if keydown(KEY_OK) and etat_carte[_n]==1 and n_carte<2: etat_carte[_n]=2 animation1(_x,_y,n) objects(_x+(2*n),_y+(7*n),n,memo[_n]) n_carte+=1 if n_carte==1:n_memo=_n elif memo[n_memo]==memo[_n]:n_carte=0;n_coup+=1 else:etat_carte[n_memo]=1;etat_carte[_n]=1;n_carte=0;sleep(0.5);memory(etat_carte);n_coup+=1 Pressed=True if Pressed:sleep(0.1) a=0 for i in etat_carte: if i==1:a+=1 if a==0 or keydown(KEY_BACKSPACE):Won=True;sleep(0.5) fill_rect(0,0,320,222,(255,)*3) animation1(90,6,7) draw_string("You Won!",120,28) draw_string("Trys:",135,68) draw_string(str(n_coup),150,88) draw_string("Record:",125,118) draw_string("13",150,138) draw_string("great!",130,178)