#include #include #include #include #include "images.h" #include "jeu.h" #include int jeu(int position[20][4], int nb_paires,int tab[40]){ int score=0,score2,repet,test=0; int pos_x,pos_y; int i,j,g,n=0,x=0, stock_g_1, stock_g_2; int repet2, nb_images, nb_trouves[40]; int clic_x,clic_y,im_y,im_x, indice1, indice2; unsigned long temps, temps2,temps3=1; char tempstab[50],affichage[50],scoretab[50], position_triche[20][4]; couleur c=CouleurParComposante(0,0,0); temps2=Microsecondes(); ChargerImage("./Images/score.png",760,250,0,0,224,63); printf("Voici le nombre de paires: %d\n", nb_paires); nb_images=nb_paires*2; score=0; c=CouleurParComposante(255,255,255); ChoisirCouleurDessin(c); RemplirRectangle(850,320,50,50); snprintf(scoretab,50,"%d",score); c=CouleurParComposante(0,0,0); ChoisirCouleurDessin(c); EcrireTexte(865,360,scoretab,2); for (i=0;i<40;i++){ nb_trouves[i]=0; } for (i=0;i<4;i++){ for (j=0;j<20;j++){ position_triche[j][i]=position[j][i]; } } while(score=10;pos_y=pos_y-90){ if (clic_y>=pos_y){ if (clic_y<=pos_y+80){ im_y=pos_y; break; } } } for (pos_x=640;pos_x>=10;pos_x=pos_x-90){ if (clic_x>=pos_x){ if (clic_x<=pos_x+80){ im_x=pos_x; break; } } } if (im_x!=0 && im_y!=0){ for (i=0;i<20;i++){ for (j=0;j<2;j++){ if (position[i][(j*2)]==im_x && position[i][(j*2+1)]==im_y){ g=i+1; if (repet==0){ stock_g_1=g; } else{ stock_g_2=g; } snprintf(affichage,50,"Images/image%d.png",g); printf("%s\n", affichage); ChargerImage(affichage,im_x,im_y,0,0,80,80); repet++; } } } } } } /*printf("%d\n", im_x); printf("%d\n", im_y);*/ if (stock_g_1==stock_g_2){ position[stock_g_1-1][0]=0; position[stock_g_1-1][1]=0; position[stock_g_1-1][2]=0; position[stock_g_1-1][3]=0; score++; for (i=0;i<40;i++){ if (tab[i]==stock_g_1){ printf("oui"); nb_trouves[i]=tab[i]; } } } repet2=0; i=0; if (score!=nb_paires){ sleep(1); for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ snprintf(affichage, 50,"Images/image%d.png",nb_trouves[i]); ChargerImage(affichage,pos_x,pos_y,0,0,80,80); repet2++; i++; if (repet2==nb_images){ pos_x=750; pos_y=380; } } } } if(score2!=score){ c=CouleurParComposante(255,255,255); ChoisirCouleurDessin(c); RemplirRectangle(850,320,50,50); snprintf(scoretab,50,"%d",score); c=CouleurParComposante(0,0,0); ChoisirCouleurDessin(c); EcrireTexte(865,360,scoretab,2); } score2=score; } ChargerImage("./Images/FIN.png",300,460,0,0,399,87); Touche(); FermerGraphique(); return 1; }