2022-11-30 17:23:59 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <graph.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "images.h"
|
|
|
|
#include "jeu.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2022-11-30 21:06:30 +01:00
|
|
|
int jeu(int position[20][4]){
|
2022-11-30 22:19:45 +01:00
|
|
|
int score=0,repet,test=0;
|
2022-11-30 21:06:30 +01:00
|
|
|
int pos_x,pos_y;
|
2022-11-30 17:41:26 +01:00
|
|
|
int i,j,g;
|
|
|
|
int clic_x,clic_y,im_y,im_x;
|
2022-11-30 22:19:45 +01:00
|
|
|
unsigned long temps, temps2,temps3;
|
2022-11-30 21:06:30 +01:00
|
|
|
char tempstab[50],affichage[50];;
|
|
|
|
char* comparer[2];
|
2022-11-30 22:19:45 +01:00
|
|
|
int tab[3];
|
|
|
|
couleur c=CouleurParComposante(0,0,0);
|
2022-11-30 21:06:30 +01:00
|
|
|
temps2=Microsecondes();
|
2022-11-30 17:23:59 +01:00
|
|
|
while(score<20){
|
2022-11-30 21:06:30 +01:00
|
|
|
temps=(Microsecondes()-temps2)/1000000;
|
2022-11-30 22:19:45 +01:00
|
|
|
//if(temps!=temps3){
|
|
|
|
snprintf(tempstab,50,"%ld secondes ecoulees",temps);
|
|
|
|
c=CouleurParComposante(0,0,0);
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
RemplirRectangle(863,83,120,20);
|
|
|
|
c=CouleurParComposante(255,255,255);
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
EcrireTexte(867,100,tempstab,0);
|
|
|
|
//}
|
|
|
|
temps3=temps;
|
2022-11-30 17:23:59 +01:00
|
|
|
for (repet=0;repet<3;repet++){
|
|
|
|
if (SourisCliquee()){
|
|
|
|
clic_x=_X;
|
|
|
|
clic_y=_Y;
|
|
|
|
|
|
|
|
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++){
|
2022-11-30 21:06:30 +01:00
|
|
|
if (position[i][(j*2)]==im_x){
|
|
|
|
if (position[i][(j*2+1)]==im_y){
|
2022-11-30 17:23:59 +01:00
|
|
|
g=i+1;
|
|
|
|
snprintf(affichage,50,"Images/image%d.png",g);
|
|
|
|
comparer[repet]=affichage;
|
|
|
|
ChargerImage(affichage,im_x,im_y,0,0,80,80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-30 22:19:45 +01:00
|
|
|
/*pour faire ça on va stocker temporairement quelles images (position) on a retournées dans tab[3],
|
|
|
|
on check si toutes les cases du tableau sont utilisées et si oui alors on sleep(1) et on recharge l'image 0
|
|
|
|
sur les positions enregistrées dans le tab ensuite on revient au début de la boucle et on reset le tab[3] à 0.*/
|
2022-11-30 17:23:59 +01:00
|
|
|
}
|
2022-11-30 17:41:26 +01:00
|
|
|
return score;
|
2022-11-30 17:23:59 +01:00
|
|
|
}
|