ajout timer 1
This commit is contained in:
parent
9f1927e1cf
commit
2fdcd8330e
BIN
JEUX_SERPENT/.nfs0000000002e8cfdb00000009
Executable file
BIN
JEUX_SERPENT/.nfs0000000002e8cfdb00000009
Executable file
Binary file not shown.
@ -1,24 +1,41 @@
|
|||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include<graph.h>
|
#include<graph.h>
|
||||||
|
#include<string.h>
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
|
/*variables*/
|
||||||
|
int seconde=0;
|
||||||
|
int minute=0;
|
||||||
|
char t;
|
||||||
|
char y;
|
||||||
|
char timer[4] = {'0',':','0','\0'};
|
||||||
|
|
||||||
/* taille de la fenêtre */
|
/* taille de la fenêtre */
|
||||||
InitialiserGraphique();
|
InitialiserGraphique();
|
||||||
CreerFenetre(10,10,1200,800);
|
CreerFenetre(350,100,1200,800);
|
||||||
|
|
||||||
/* Couleur de la fenêtre */
|
/* Couleur de la fenêtre */
|
||||||
EffacerEcran(CouleurParComposante(0,0,0));
|
EffacerEcran(CouleurParComposante(0,0,0));
|
||||||
ChoisirCouleurDessin(CouleurParComposante(141,199,63));
|
ChoisirCouleurDessin(CouleurParComposante(141,199,63));
|
||||||
RemplirRectangle(10,10,1180,700);
|
RemplirRectangle(10,10,1180,700);
|
||||||
|
|
||||||
/*Affichage du score*/
|
/*Affichage du timer (timer Ok, mais pas l'affichage)*/
|
||||||
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||||||
EcrireTexte(10,760,"Score",2);
|
while(1){
|
||||||
|
EcrireTexte(10,760,timer,2);
|
||||||
/*Appartion du serpent*/
|
t=(char)seconde;
|
||||||
|
y=(char)minute;
|
||||||
|
timer[0]= y;
|
||||||
|
timer[2]= t;
|
||||||
|
seconde=seconde+1;
|
||||||
|
if(seconde>=60){
|
||||||
|
seconde=0;
|
||||||
|
minute=minute+1;
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* fermeture de la fenêtre */
|
/* fermeture de la fenêtre */
|
||||||
Touche();
|
Touche();
|
||||||
|
20
JEUX_SERPENT/timer.c
Normal file
20
JEUX_SERPENT/timer.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*timer de base (à mettre plus tard dans un fichier makefile)*/
|
||||||
|
int main(void){
|
||||||
|
int seconde=0;
|
||||||
|
int minute=0;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
sleep(1);
|
||||||
|
seconde=seconde+1;
|
||||||
|
if(seconde>=60) {
|
||||||
|
seconde=0;
|
||||||
|
minute=minute+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user