From 850d86b4565165dc4fef9929d3852c8e1a380e12 Mon Sep 17 00:00:00 2001 From: morinl Date: Wed, 30 Nov 2022 21:06:30 +0100 Subject: [PATCH] on tente des trucs --- Makefile | 4 ++-- images.c | 10 +++------- jeu.c | 20 ++++++++++++-------- jeu.h | 2 +- main.c | 11 +---------- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 4217e3a..406fb4b 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,12 @@ jeu: main.o images.o menu.o temps.o jeu.o $(CC) -o jeu main.o images.o menu.o temps.o $(LDFLAGS) main.o: main.c images.h menu.h main.h $(CC) main.c $(CFLAGS) -images.o: images.c images.h +images.o: images.c images.h jeu.h $(CC) images.c $(CFLAGS) menu.o: menu.c menu.h $(CC) menu.c $(CFLAGS) temps.o: temps.c temps.h $(CC) temps.c $(CFLAGS) -jeu.o: jeu.c jeu.h +jeu.o: jeu.c jeu.h images.h $(CC) jeu.c $(CFLAGS) run:./jeu \ No newline at end of file diff --git a/images.c b/images.c index ff2e1a8..a7c7553 100644 --- a/images.c +++ b/images.c @@ -8,14 +8,13 @@ int tirage_aleatoire(void){ InitialiserGraphique(); - char tirage[50], affichage[50]; + char tirage[50]; int pos_x, pos_y, clic_x, clic_y, im_y, im_x; int i, j; - int nb; + int nb,score; int tab[40]; int nb_paires=20; int positions[20][4]; - char* comparer[2]; ChargerImage("Images/background.png",0,0,0,0,1024,576); @@ -82,12 +81,9 @@ int tirage_aleatoire(void){ } printf("\n"); }*/ - jeu(); + score=jeu(positions); Touche(); FermerGraphique(); printf("\n"); return EXIT_SUCCESS; } - - - diff --git a/jeu.c b/jeu.c index ec0999a..6598338 100644 --- a/jeu.c +++ b/jeu.c @@ -3,18 +3,22 @@ #include #include #include "images.h" -#include "temps.h" #include "jeu.h" #include -int jeu(void){ - int temps,score,repet; +int jeu(int position[20][4]){ + int score,repet; + int pos_x,pos_y; int i,j,g; int clic_x,clic_y,im_y,im_x; - char tempstab[50]; + unsigned long temps, temps2; + char tempstab[50],affichage[50];; + char* comparer[2]; + temps2=Microsecondes(); while(score<20){ - temps=timer(); - snprintf(tempstab,50,"%d secondes écoulées",temps); + temps=(Microsecondes()-temps2)/1000000; + snprintf(tempstab,50,"%ld secondes écoulées",temps); + EcrireTexte(500,100,tempstab,1); for (repet=0;repet<3;repet++){ if (SourisCliquee()){ clic_x=_X; @@ -43,8 +47,8 @@ int jeu(void){ 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){ + if (position[i][(j*2)]==im_x){ + if (position[i][(j*2+1)]==im_y){ g=i+1; snprintf(affichage,50,"Images/image%d.png",g); comparer[repet]=affichage; diff --git a/jeu.h b/jeu.h index e34c20d..34bb885 100644 --- a/jeu.h +++ b/jeu.h @@ -1,6 +1,6 @@ #ifndef JEU_H #define JEU_H -int jeu(void); +int jeu(int positions[20][4]); #endif \ No newline at end of file diff --git a/main.c b/main.c index e02f4a4..0688723 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,6 @@ #include "images.h" #include "menu.h" #include "main.h" -#include "temps.h" /*faire les includes des autres parties du programme*/ @@ -12,15 +11,7 @@ int main(void){ int temps,coucou; int test=menu(); char tableautemps[50]; - 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