2023-12-01 13:32:18 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <graph.h>
|
2023-12-14 15:00:02 +01:00
|
|
|
#include "../fichier.h/time.h"
|
2023-12-19 17:27:47 +01:00
|
|
|
#include "../fichier.h/main.h"
|
|
|
|
#include "../fichier.h/serpent.h"
|
2023-12-01 13:32:18 +01:00
|
|
|
#define CYCLE 10000L
|
|
|
|
|
2023-12-19 17:27:47 +01:00
|
|
|
int seconde=0;
|
|
|
|
int minute=0;
|
|
|
|
int seconde_actuel=0;
|
|
|
|
int old_seconde=0;
|
|
|
|
unsigned long int suivant;
|
|
|
|
char timer[6];
|
|
|
|
|
|
|
|
void Score(int segment){
|
|
|
|
int nombre;
|
|
|
|
char score[4];
|
|
|
|
nombre= (segment-10)*10;
|
|
|
|
snprintf(score,4,"%04d0", nombre);
|
|
|
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
|
|
|
RemplirRectangle(1100,700,1200,800);
|
|
|
|
ChoisirCouleurDessin(CouleurParNom("white"));
|
|
|
|
EcrireTexte(1000,760,"Score: ",2);
|
|
|
|
EcrireTexte(1100,760,score,2);
|
|
|
|
}
|
|
|
|
void Update_Timer(){
|
2023-12-14 15:00:02 +01:00
|
|
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
|
|
|
RemplirRectangle(10,700,12000,800);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
2023-12-19 17:27:47 +01:00
|
|
|
EcrireTexte(50,760,"time: ",2);
|
|
|
|
EcrireTexte(120,760,timer,2);
|
2023-12-01 13:32:18 +01:00
|
|
|
}
|
2023-12-19 17:27:47 +01:00
|
|
|
void Timer(){
|
2023-12-14 15:00:02 +01:00
|
|
|
if(Microsecondes()> suivant){
|
|
|
|
suivant = Microsecondes()+CYCLE;
|
|
|
|
seconde_actuel = (suivant/1000000)%10;
|
|
|
|
if(seconde_actuel !=old_seconde){
|
|
|
|
old_seconde = seconde_actuel;
|
|
|
|
if(seconde == 59){
|
|
|
|
minute=minute+1;
|
|
|
|
seconde=0;
|
|
|
|
Update_Timer();
|
|
|
|
}else;{
|
|
|
|
seconde = seconde+1;
|
|
|
|
Update_Timer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-01 13:32:18 +01:00
|
|
|
}
|
2023-12-04 17:27:48 +01:00
|
|
|
|