From 08d3e9afe7208536b957a1cb524ebbf396a89010 Mon Sep 17 00:00:00 2001 From: morinl Date: Wed, 30 Nov 2022 17:13:06 +0100 Subject: [PATCH] Ajout de temps dans Makefile+tentative affichage --- .gitignore | 1 + Makefile | 9 +++++---- main.c | 17 +++++++++-------- temps.c | 4 ++-- temps.h | 6 ++++++ 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 temps.h diff --git a/.gitignore b/.gitignore index 3417814..acd6a2a 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ tags # Persistent undo [._]*.un~ +jeu diff --git a/Makefile b/Makefile index f5bdf34..9af7a4b 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,14 @@ CFLAGS= -Wall -c -lgraph LDFLAGS= -Wall -lgraph EXEC=menu -jeu: main.o images.o menu.o - $(CC) -o jeu main.o images.o menu.o $(LDFLAGS) -main.o: main.c images.h menu.h main.h +jeu: main.o images.o menu.o temps.o + $(CC) -o jeu main.o images.o menu.o temps.o $(LDFLAGS) +main.o: main.c images.h menu.h main.h temps.h $(CC) main.c $(CFLAGS) images.o: images.c images.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) run:./jeu \ No newline at end of file diff --git a/main.c b/main.c index 9dd5c27..e125d15 100644 --- a/main.c +++ b/main.c @@ -4,19 +4,20 @@ #include "images.h" #include "menu.h" #include "main.h" +#include "temps.h" /*faire les includes des autres parties du programme*/ int main(void){ + int temps; int test=menu(); - printf("%d\n",test); - /*chargement(); - while (SourisCliquee()!=1){ - if (SourisCliquee()==1){ - return EXIT_SUCCESS; - } - printf("1"); - }*/ + char tableautemps[50]; + 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; diff --git a/temps.c b/temps.c index beadb03..e0d1b98 100644 --- a/temps.c +++ b/temps.c @@ -2,6 +2,7 @@ #include #include #include +#include "temps.h" //faire une boucle tant que le jeu n'est pas fini //affichage de texte pour afficher le timer int timer(void){ @@ -11,7 +12,6 @@ int timer(void){ temps=Microsecondes(); while (ToucheEnAttente(XK_Escape)!=1){ temps2=(Microsecondes()-temps)/1000000; - printf("temps:%lu secondes écoulées\n",temps2); } - FermerGraphique(); + return temps2; } \ No newline at end of file diff --git a/temps.h b/temps.h new file mode 100644 index 0000000..70c1b0b --- /dev/null +++ b/temps.h @@ -0,0 +1,6 @@ +#ifndef TEMPS_H +#define TEMPS_H + +int timer(void); + +#endif \ No newline at end of file