les images se retournent

This commit is contained in:
Mathieu PROAL 2022-11-29 18:05:27 +01:00
parent afc1be0346
commit 1084712014

View File

@ -4,9 +4,9 @@
#include <time.h> #include <time.h>
#include "images.h" #include "images.h"
int main(void){ int tirage_aleatoire(void){
InitialiserGraphique(); 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 pos_x, pos_y, clic_x, clic_y, im_y, im_x;
int i, j, g; int i, j, g;
int nb, score=0; int nb, score=0;
@ -39,13 +39,12 @@ int main(void){
} }
} }
} }
printf("toto\n");
/*Affichage des images*/ /*Affichage des images*/
srand(time(NULL)); srand(time(NULL));
i=0; i=0;
for (pos_y=10;pos_y<380;pos_y=pos_y+90){ for (pos_y=10;pos_y<=370;pos_y=pos_y+90){
for (pos_x=10;pos_x<650;pos_x=pos_x+90){ for (pos_x=10;pos_x<=640;pos_x=pos_x+90){
/*if (tab[i]==-1){ /*if (tab[i]==-1){
pos_y=1000; pos_y=1000;
}*/ }*/
@ -57,48 +56,59 @@ int main(void){
positions[tab[i]][2]=pos_x; positions[tab[i]][2]=pos_x;
positions[tab[i]][3]=pos_y; positions[tab[i]][3]=pos_y;
} }
/*Triche*/ /*Triche
snprintf(tirage,50,"Images/image%d.png",(tab[i]+1)); 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++; i++;
} }
} }
/*for (j=0;j<4;j++){
for (i=0;i<20;i++){
printf("%03d", positions[i][j]);
printf(" ");
}
printf("\n");
}*/
while(score<=20){ while(score<=20){
if (SourisCliquee()){ if (SourisCliquee()){
SourisPosition();
clic_x=_X; clic_x=_X;
clic_y=_Y; clic_y=_Y;
}
im_x=0;
im_y=0;
for (pos_y=380;pos_y>10;pos_y=pos_y-90){ for (pos_y=370;pos_y>=10;pos_y=pos_y-90){
if (clic_y>=pos_y){ if (clic_y>=pos_y){
if (clic_y<=pos_y+80){ if (clic_y<=pos_y+80){
im_y=pos_y; im_y=pos_y;
pos_y=0; break;
}
} }
} }
} for (pos_x=640;pos_x>=10;pos_x=pos_x-90){
for (pos_x=650;pos_x>10;pos_x=pos_x-90){ if (clic_x>=pos_x){
if (clic_x>=pos_x){ if (clic_x<=pos_x+80){
if (clic_x<=pos_x+80){ im_x=pos_x;
im_x=pos_x; break;
pos_x=0; }
} }
} }
}
for (i=0;i<20;i++){ if (im_x!=0 && im_y!=0){
for (j=0;j<2;j++){ for (i=0;i<20;i++){
if (positions[i][(j*2)]==im_x){ for (j=0;j<2;j++){
if (positions[i][(j*2+1)]==im_y){ if (positions[i][(j*2)]==im_x){
g=i+1; if (positions[i][(j*2+1)]==im_y){
snprintf(affichage,10,"Images/image%d.png",g); g=i+1;
ChargerImage(affichage,pos_x,pos_y,0,0,80,80); snprintf(affichage,50,"Images/image%d.png",g);
ChargerImage(affichage,im_x,im_y,0,0,80,80);
}
}
} }
} }
} }