CA MARCHE

This commit is contained in:
proal 2022-12-01 23:17:52 +01:00
parent c5215d29b9
commit 43f56c5c4c

40
jeu.c
View File

@ -9,12 +9,12 @@
int jeu(int position[20][4], int nb_paires){ int jeu(int position[20][4], int nb_paires){
int score=0,repet,test=0; int score=0,repet,test=0;
int pos_x,pos_y; int pos_x,pos_y;
int i,j,g; int i,j,g, stock_g_1, stock_g_2;
int repet2, nb_images; int repet2, nb_images;
int clic_x,clic_y,im_y,im_x; int clic_x,clic_y,im_y,im_x;
unsigned long temps, temps2,temps3; unsigned long temps, temps2,temps3;
char tempstab[50],affichage[50];; char tempstab[50],affichage[50];;
char* comparer[200]; char* comparer1[50], comparer2[50];
int tab[3]; int tab[3];
couleur c=CouleurParComposante(0,0,0); couleur c=CouleurParComposante(0,0,0);
temps2=Microsecondes(); temps2=Microsecondes();
@ -36,8 +36,8 @@ int jeu(int position[20][4], int nb_paires){
//} //}
temps3=temps; temps3=temps;
repet=0; repet=0;
comparer[0]="vide"; /*comparer[0]="vide";
comparer[1]="vide"; comparer[1]="vide";*/
while (repet<2){ while (repet<2){
if (SourisCliquee()){ if (SourisCliquee()){
clic_x=_X; clic_x=_X;
@ -67,17 +67,18 @@ int jeu(int position[20][4], int nb_paires){
for (i=0;i<20;i++){ for (i=0;i<20;i++){
for (j=0;j<2;j++){ for (j=0;j<2;j++){
if (position[i][(j*2)]==im_x && position[i][(j*2+1)]==im_y){ if (position[i][(j*2)]==im_x && position[i][(j*2+1)]==im_y){
g=i+1; if (repet==0){
snprintf(affichage,50,"Images/image%d.png",g); g=i+1;
printf("Voici repet: %d\n", repet); snprintf(comparer1,50,"Images/image%d.png",g);
printf("Voici affichage: %s\n", affichage); ChargerImage(comparer1,im_x,im_y,0,0,80,80);
if (repet==0){ stock_g_1=g;
comparer[repet]=affichage; }
} else{
printf("Voici comparer[repet]: %s\n", comparer[repet]); g=i+1;
printf("Voici comparer[0]: %s\n", comparer[0]); snprintf(comparer2,50,"Images/image%d.png",g);
printf("Voici comparer[1]: %s\n\n", comparer[1]); ChargerImage(comparer2,im_x,im_y,0,0,80,80);
ChargerImage(affichage,im_x,im_y,0,0,80,80); stock_g_2=g;
}
repet++; repet++;
} }
} }
@ -85,16 +86,13 @@ int jeu(int position[20][4], int nb_paires){
} }
} }
} }
printf("Voici comparer[0]: %s\n", comparer[0]);
printf("Voici comparer[1]: %s\n", comparer[1]);
printf("Voici affichage: %s\n", affichage);
/*printf("%d\n", im_x); /*printf("%d\n", im_x);
printf("%d\n", im_y);*/ printf("%d\n", im_y);*/
if (comparer[0]==affichage){ if (stock_g_1==stock_g_2){
score++; score++;
} }
repet2=0; repet2=0;
if (score!=20){ if (score!=nb_paires){
sleep(1); sleep(1);
for (pos_y=10;pos_y<=370;pos_y=pos_y+90){ for (pos_y=10;pos_y<=370;pos_y=pos_y+90){
for (pos_x=10;pos_x<=640;pos_x=pos_x+90){ for (pos_x=10;pos_x<=640;pos_x=pos_x+90){
@ -110,5 +108,5 @@ int jeu(int position[20][4], int nb_paires){
} }
Touche(); Touche();
FermerGraphique(); FermerGraphique();
return EXIT_SUCCESS; return 1;
} }