From 0ad6f31c5a8b482bf954dea2971cc428f159c716 Mon Sep 17 00:00:00 2001 From: morinl Date: Wed, 30 Nov 2022 17:23:59 +0100 Subject: [PATCH] creation jeu.c modif images.c --- images.c | 57 ++------------------------------------------------------ jeu.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ jeu.h | 6 ++++++ main.c | 8 +++++--- 4 files changed, 67 insertions(+), 58 deletions(-) create mode 100644 jeu.c create mode 100644 jeu.h diff --git a/images.c b/images.c index c473c13..d4c3b65 100644 --- a/images.c +++ b/images.c @@ -4,6 +4,7 @@ #include #include "images.h" #include +#include "jeu.h" int tirage_aleatoire(void){ InitialiserGraphique(); @@ -82,61 +83,7 @@ int tirage_aleatoire(void){ } printf("\n"); }*/ - - while(score<20){ - 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++){ - 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); - comparer[repet]=affichage; - ChargerImage(affichage,im_x,im_y,0,0,80,80); - } - } - } - } - } - } - } - if (comparer[0]==comparer[1]){ - score++; - } - if (score!=20){ - sleep(1); - for (pos_y=10;pos_y<=370;pos_y=pos_y+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); - } - } - } - } + jeu() Touche(); FermerGraphique(); printf("\n"); diff --git a/jeu.c b/jeu.c new file mode 100644 index 0000000..352eedf --- /dev/null +++ b/jeu.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include "images.h" +#include "temps.h" +#include "jeu.h" +#include + +int jeu(void){ + while(score<20){ + 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++){ + 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); + comparer[repet]=affichage; + ChargerImage(affichage,im_x,im_y,0,0,80,80); + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/jeu.h b/jeu.h new file mode 100644 index 0000000..e34c20d --- /dev/null +++ b/jeu.h @@ -0,0 +1,6 @@ +#ifndef JEU_H +#define JEU_H + +int jeu(void); + +#endif \ No newline at end of file diff --git a/main.c b/main.c index e125d15..e02f4a4 100644 --- a/main.c +++ b/main.c @@ -9,16 +9,18 @@ int main(void){ - int temps; + int temps,coucou; int test=menu(); char tableautemps[50]; - while(tirage_aleatoire()!=1){ + while(1){ + coucou=tirage_aleatoire(); + while(tirage_aleatoire()!=1){ temps=timer(); printf("%d",temps); snprintf(tableautemps,50,"%d secondes écoulées",temps); EcrireTexte(500,100,tableautemps,1); + } } - tirage_aleatoire(); FermerGraphique(); return EXIT_SUCCESS; } \ No newline at end of file