#include #include #include #include #include "images.h" #include int tirage_aleatoire(void){ InitialiserGraphique(); char tirage[50], affichage[50]; int pos_x, pos_y, clic_x, clic_y, im_y, im_x; int i, j, g; int nb, score=0; int tab[40]; int nb_paires=20; int positions[20][4]; int repet; char* comparer[2]; ChargerImage("Images/background.png",0,0,0,0,1024,576); /*Initialisation des tableaux*/ for (i=0;i<20;i++){ for (j=0;j<4;j++){ positions[i][j]=0; } } for (i=0;i<40;i++){ tab[i]=-1; } /*Tirage des images*/ srand(time(NULL)); for (i=0;i<2;i++){ for (j=0;j=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 (positions[i][(j*2)]==im_x){ if (positions[i][(j*2+1)]==im_y){ g=i+1; snprintf(affichage,50,"Images/image%d.png",g); comparer[repet]=affichage; ChargerImage(affichage,im_x,im_y,0,0,80,80); } } } } } } } if (comparer[0]==comparer[1]){ score++; } if (score!=20){ 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){ ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80); } } } } Touche(); FermerGraphique(); printf("\n"); return EXIT_SUCCESS; }