2023-12-04 17:01:52 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <graph.h>
|
2023-12-07 14:02:18 +01:00
|
|
|
#include "fonction.h"
|
2023-12-22 11:44:28 +01:00
|
|
|
#define CYCLE 10000L
|
2023-12-04 17:01:52 +01:00
|
|
|
|
2023-12-21 11:33:41 +01:00
|
|
|
int seconde=0, minute=0, seconde_actuel=0;
|
|
|
|
int imageMenuFin;
|
2023-12-22 11:44:28 +01:00
|
|
|
int imageMenuDebut;
|
|
|
|
char timer[6];
|
|
|
|
char score[4];
|
2023-12-21 11:33:41 +01:00
|
|
|
|
2023-12-04 17:01:52 +01:00
|
|
|
/*Fonction pour calculer le temps*/
|
2023-12-22 11:44:28 +01:00
|
|
|
int Timer(unsigned long int suivant, int old_seconde){
|
2023-12-04 17:01:52 +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;
|
|
|
|
}else{
|
|
|
|
seconde = seconde+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-22 11:44:28 +01:00
|
|
|
Update_Timer();
|
|
|
|
return old_seconde;
|
2023-12-04 17:01:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Fonction pour mettre à jour unuquement le timer*/
|
|
|
|
void Update_Timer(){
|
|
|
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
2023-12-10 13:11:43 +01:00
|
|
|
RemplirRectangle(0,700,1200,800);
|
2023-12-04 17:01:52 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
|
|
|
EcrireTexte(10,760,timer,2);
|
2023-12-12 15:00:17 +01:00
|
|
|
}
|
|
|
|
|
2023-12-19 15:44:28 +01:00
|
|
|
/*fonction afin de créer un délai (en microseconde*/
|
2023-12-12 15:00:17 +01:00
|
|
|
void Attendre(long int microsecondes){
|
2023-12-18 13:36:17 +01:00
|
|
|
long int attendre;
|
2023-12-12 15:00:17 +01:00
|
|
|
attendre = Microsecondes()+ microsecondes;
|
|
|
|
while (Microsecondes() < attendre){
|
|
|
|
}
|
2023-12-21 11:33:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*création du Menu de Fin*/
|
|
|
|
void MenuDeFin(int Nbr){
|
|
|
|
EffacerEcran(CouleurParComposante(0,0,0));
|
2023-12-21 12:12:52 +01:00
|
|
|
imageMenuFin=ChargerSprite("IMG/menu2.png");
|
2023-12-21 11:33:41 +01:00
|
|
|
AfficherSprite(imageMenuFin,0,0);
|
2023-12-21 12:12:52 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
2023-12-21 11:33:41 +01:00
|
|
|
snprintf(score,15,"Score : %04d", Nbr);
|
2023-12-21 12:12:52 +01:00
|
|
|
EcrireTexte(500,650,score,2);
|
2023-12-21 11:33:41 +01:00
|
|
|
snprintf(timer,14,"Temps : %02d:%02d", minute, seconde);
|
2023-12-21 12:12:52 +01:00
|
|
|
EcrireTexte(490,700,timer,2);
|
|
|
|
EcrireTexte(410,750,"Appuyer sur Q pour quitter",2);
|
2023-12-22 11:44:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*création du menu d'accueil*/
|
|
|
|
void MenuDebut(){
|
|
|
|
imageMenuDebut=ChargerSprite("IMG/menu1.png");
|
|
|
|
AfficherSprite(imageMenuDebut,0,0);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
|
|
|
EcrireTexte(410,650,"Appuyer sur Q pour quitter",2);
|
|
|
|
EcrireTexte(290,750,"Appuyer sur Fleche de Droite pour lancer le jeu",2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*fonction pour afficher + calculer le score*/
|
|
|
|
int Score(int segment, int Nbr){
|
|
|
|
Nbr=(segment-10)*2.5;
|
|
|
|
snprintf(score,5,"%04d", Nbr);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
|
|
|
RemplirRectangle(1100,730,1200,800);
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
|
|
|
EcrireTexte(1000,750,"Score :",2);
|
|
|
|
EcrireTexte(1100,750,score,2);
|
|
|
|
return Nbr;
|
2023-12-04 17:01:52 +01:00
|
|
|
}
|