From 108471201433d3db789b07ebcf36009bffd57ec5 Mon Sep 17 00:00:00 2001 From: proal Date: Tue, 29 Nov 2022 18:05:27 +0100 Subject: [PATCH] les images se retournent --- images.c | 80 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/images.c b/images.c index 6e7ba58..d35f5d3 100644 --- a/images.c +++ b/images.c @@ -4,9 +4,9 @@ #include #include "images.h" -int main(void){ +int tirage_aleatoire(void){ InitialiserGraphique(); - char tirage[50], affichage[10]; + 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; @@ -39,13 +39,12 @@ int main(void){ } } } - printf("toto\n"); /*Affichage des images*/ srand(time(NULL)); i=0; - for (pos_y=10;pos_y<380;pos_y=pos_y+90){ - for (pos_x=10;pos_x<650;pos_x=pos_x+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){ /*if (tab[i]==-1){ pos_y=1000; }*/ @@ -57,48 +56,59 @@ int main(void){ positions[tab[i]][2]=pos_x; positions[tab[i]][3]=pos_y; } - /*Triche*/ + /*Triche snprintf(tirage,50,"Images/image%d.png",(tab[i]+1)); - ChargerImage(tirage,pos_x,pos_y,0,0,80,80); + ChargerImage(tirage,pos_x,pos_y,0,0,80,80);*/ - ///ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80); + ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80); i++; } } + /*for (j=0;j<4;j++){ + for (i=0;i<20;i++){ + printf("%03d", positions[i][j]); + printf(" "); + } + printf("\n"); + }*/ + while(score<=20){ if (SourisCliquee()){ - SourisPosition(); clic_x=_X; clic_y=_Y; - } - - - for (pos_y=380;pos_y>10;pos_y=pos_y-90){ - if (clic_y>=pos_y){ - if (clic_y<=pos_y+80){ - im_y=pos_y; - pos_y=0; - } - } - } - for (pos_x=650;pos_x>10;pos_x=pos_x-90){ - if (clic_x>=pos_x){ - if (clic_x<=pos_x+80){ - im_x=pos_x; - pos_x=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,10,"Images/image%d.png",g); - ChargerImage(affichage,pos_x,pos_y,0,0,80,80); + im_x=0; + im_y=0; + + for (pos_y=370;pos_y>=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); + ChargerImage(affichage,im_x,im_y,0,0,80,80); + } + } } } }