2023-12-01 13:32:18 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <graph.h>
|
2023-12-21 21:45:49 +01:00
|
|
|
#include "time.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "serpent.h"
|
2023-12-21 12:29:12 +01:00
|
|
|
#define CYCLE 100000L
|
2023-12-01 13:32:18 +01:00
|
|
|
|
2023-12-19 17:27:47 +01:00
|
|
|
void Score(int segment){
|
|
|
|
int nombre;
|
|
|
|
char score[4];
|
2023-12-20 21:26:34 +01:00
|
|
|
nombre= (segment-10)*25;
|
2023-12-19 17:27:47 +01:00
|
|
|
snprintf(score,4,"%04d0", nombre);
|
2023-12-21 14:32:41 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
|
|
|
RemplirRectangle(950,725,1300,800);
|
2023-12-19 17:27:47 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParNom("white"));
|
|
|
|
EcrireTexte(1000,760,"Score: ",2);
|
|
|
|
EcrireTexte(1100,760,score,2);
|
|
|
|
}
|
2023-12-20 21:26:34 +01:00
|
|
|
void Update_Timer(int minute, int seconde, char timer[]){
|
2023-12-14 15:00:02 +01:00
|
|
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
2023-12-21 14:32:41 +01:00
|
|
|
RemplirRectangle(20,735,200,75);
|
2023-12-14 15:00:02 +01:00
|
|
|
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-20 21:26:34 +01:00
|
|
|
void Timer(int *minute, int *seconde, unsigned long int *suivant, int *seconde_actuel, int *old_seconde, char timer[]){
|
|
|
|
if(Microsecondes()> *suivant){
|
|
|
|
*suivant = Microsecondes()+CYCLE;
|
|
|
|
*seconde_actuel = (*suivant/1000000)%10;
|
2023-12-14 15:00:02 +01:00
|
|
|
if(seconde_actuel !=old_seconde){
|
2023-12-20 21:26:34 +01:00
|
|
|
*old_seconde = *seconde_actuel;
|
|
|
|
if(*seconde == 59){
|
|
|
|
*minute=*minute+1;
|
|
|
|
*seconde=0;
|
|
|
|
Update_Timer(*minute, *seconde, timer);
|
|
|
|
}else{
|
|
|
|
*seconde = *seconde+1;
|
|
|
|
Update_Timer(*minute, *seconde, timer);
|
2023-12-14 15:00:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-20 21:26:34 +01:00
|
|
|
}
|