j'ai cassé ce que lionel a fait
This commit is contained in:
parent
54e2083393
commit
4acf60c5ec
4
images.c
4
images.c
@ -76,7 +76,11 @@ int tirage_aleatoire(int nb_paires){
|
|||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
|
for (i=0;i<40;i++){
|
||||||
|
printf("%d\n",tab[i]);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
score=jeu(positions, nb_paires,tab);
|
score=jeu(positions, nb_paires,tab);
|
||||||
Touche();
|
Touche();
|
||||||
FermerGraphique();
|
FermerGraphique();
|
||||||
|
66
jeu.c
66
jeu.c
@ -10,11 +10,10 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
int score=0,score2,repet,test=0;
|
int score=0,score2,repet,test=0;
|
||||||
int pos_x,pos_y;
|
int pos_x,pos_y;
|
||||||
int i,j,g,n=0,x=0, stock_g_1, stock_g_2;
|
int i,j,g,n=0,x=0, stock_g_1, stock_g_2;
|
||||||
int repet2, nb_images;
|
int repet2, nb_images, nb_trouves[40];
|
||||||
int clic_x,clic_y,im_y,im_x;
|
int clic_x,clic_y,im_y,im_x, indice1, indice2;
|
||||||
unsigned long temps, temps2,temps3=1;
|
unsigned long temps, temps2,temps3=1;
|
||||||
char tempstab[50],affichage[50],scoretab[50];
|
char tempstab[50],affichage[50],scoretab[50], position_triche[20][4];
|
||||||
char* comparer1[50], comparer2[50];
|
|
||||||
couleur c=CouleurParComposante(0,0,0);
|
couleur c=CouleurParComposante(0,0,0);
|
||||||
temps2=Microsecondes();
|
temps2=Microsecondes();
|
||||||
ChargerImage("./Images/score.png",760,250,0,0,224,63);
|
ChargerImage("./Images/score.png",760,250,0,0,224,63);
|
||||||
@ -27,6 +26,17 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
c=CouleurParComposante(0,0,0);
|
c=CouleurParComposante(0,0,0);
|
||||||
ChoisirCouleurDessin(c);
|
ChoisirCouleurDessin(c);
|
||||||
EcrireTexte(865,360,scoretab,2);
|
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<nb_paires){
|
while(score<nb_paires){
|
||||||
temps=(Microsecondes()-temps2)/1000000;
|
temps=(Microsecondes()-temps2)/1000000;
|
||||||
if(temps!=temps3){
|
if(temps!=temps3){
|
||||||
@ -40,8 +50,6 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
}
|
}
|
||||||
temps3=temps;
|
temps3=temps;
|
||||||
repet=0;
|
repet=0;
|
||||||
/*comparer[0]="vide";
|
|
||||||
comparer[1]="vide";*/
|
|
||||||
while (repet<2){
|
while (repet<2){
|
||||||
temps=(Microsecondes()-temps2)/1000000;
|
temps=(Microsecondes()-temps2)/1000000;
|
||||||
if(temps!=temps3){
|
if(temps!=temps3){
|
||||||
@ -54,6 +62,7 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
EcrireTexte(867,100,tempstab,0);
|
EcrireTexte(867,100,tempstab,0);
|
||||||
}
|
}
|
||||||
temps3=temps;
|
temps3=temps;
|
||||||
|
|
||||||
/*Triche*/
|
/*Triche*/
|
||||||
if(ToucheEnAttente() && Touche(XK_t)){
|
if(ToucheEnAttente() && Touche(XK_t)){
|
||||||
n=0;
|
n=0;
|
||||||
@ -65,13 +74,13 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
pos_x=650;
|
pos_x=650;
|
||||||
pos_y=1000;
|
pos_y=1000;
|
||||||
}
|
}
|
||||||
if (position[tab[x]][0]==0){
|
if (position_triche[tab[x]][0]==0){
|
||||||
position[tab[x]][0]=pos_x;
|
position_triche[tab[x]][0]=pos_x;
|
||||||
position[tab[x]][1]=pos_y;
|
position_triche[tab[x]][1]=pos_y;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
position[tab[x]][2]=pos_x;
|
position_triche[tab[x]][2]=pos_x;
|
||||||
position[tab[x]][3]=pos_y;
|
position_triche[tab[x]][3]=pos_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(affichage,50,"Images/image%d.png",(tab[x]+1));
|
snprintf(affichage,50,"Images/image%d.png",(tab[x]+1));
|
||||||
@ -87,13 +96,13 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
pos_x=650;
|
pos_x=650;
|
||||||
pos_y=1000;
|
pos_y=1000;
|
||||||
}
|
}
|
||||||
if (position[tab[x]][0]==0){
|
if (position_triche[tab[x]][0]==0){
|
||||||
position[tab[x]][0]=pos_x;
|
position_triche[tab[x]][0]=pos_x;
|
||||||
position[tab[x]][1]=pos_y;
|
position_triche[tab[x]][1]=pos_y;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
position[tab[x]][2]=pos_x;
|
position_triche[tab[x]][2]=pos_x;
|
||||||
position[tab[x]][3]=pos_y;
|
position_triche[tab[x]][3]=pos_y;
|
||||||
}
|
}
|
||||||
ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80);
|
ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80);
|
||||||
x++;
|
x++;
|
||||||
@ -131,18 +140,16 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
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){
|
||||||
if (repet==0){
|
|
||||||
g=i+1;
|
g=i+1;
|
||||||
snprintf(comparer1,50,"Images/image%d.png",g);
|
if (repet==0){
|
||||||
ChargerImage(comparer1,im_x,im_y,0,0,80,80);
|
|
||||||
stock_g_1=g;
|
stock_g_1=g;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
g=i+1;
|
|
||||||
snprintf(comparer2,50,"Images/image%d.png",g);
|
|
||||||
ChargerImage(comparer2,im_x,im_y,0,0,80,80);
|
|
||||||
stock_g_2=g;
|
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++;
|
repet++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,15 +160,28 @@ int jeu(int position[20][4], int nb_paires,int tab[40]){
|
|||||||
/*printf("%d\n", im_x);
|
/*printf("%d\n", im_x);
|
||||||
printf("%d\n", im_y);*/
|
printf("%d\n", im_y);*/
|
||||||
if (stock_g_1==stock_g_2){
|
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++;
|
score++;
|
||||||
|
for (i=0;i<40;i++){
|
||||||
|
if (tab[i]==stock_g_1){
|
||||||
|
printf("oui");
|
||||||
|
nb_trouves[i]=tab[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
repet2=0;
|
repet2=0;
|
||||||
|
i=0;
|
||||||
if (score!=nb_paires){
|
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){
|
||||||
ChargerImage("Images/image0.png",pos_x,pos_y,0,0,80,80);
|
snprintf(affichage, 50,"Images/image%d.png",nb_trouves[i]);
|
||||||
|
ChargerImage(affichage,pos_x,pos_y,0,0,80,80);
|
||||||
repet2++;
|
repet2++;
|
||||||
|
i++;
|
||||||
if (repet2==nb_images){
|
if (repet2==nb_images){
|
||||||
pos_x=750;
|
pos_x=750;
|
||||||
pos_y=380;
|
pos_y=380;
|
||||||
|
Loading…
Reference in New Issue
Block a user