Vrai Fix Timer + Améliorations graphiques
This commit is contained in:
52
evenement.c
52
evenement.c
@@ -5,29 +5,23 @@
|
||||
#include <time.h>
|
||||
|
||||
|
||||
void AfficherTimerEtScore(long unsigned int *score, long unsigned int temps) /*Afficher le temps passé et le score*/
|
||||
void AfficherTimerEtScore(long unsigned int *score, int minutes,int secondes) /*Afficher le temps passé et le score*/
|
||||
{
|
||||
char buf[100];
|
||||
char buff[100]; /* Stockage du score et du timer */
|
||||
couleur j;
|
||||
|
||||
time_t fin_temps;
|
||||
long int timer;
|
||||
int minutes,secondes;
|
||||
fin_temps = time(NULL); /* Gestion du timer et des variables */
|
||||
timer = difftime(fin_temps, temps);
|
||||
secondes = timer % 60;
|
||||
minutes = timer / 60;
|
||||
|
||||
j=CouleurParNom("yellow");
|
||||
ChoisirCouleurDessin(j);
|
||||
couleur text;
|
||||
text=CouleurParComposante(78, 93, 47);
|
||||
|
||||
ChoisirEcran(1);
|
||||
CopierZone(2,1,0,0,930,710,0,0);
|
||||
CopierZone(2,1,0,0,930,710,0,0);
|
||||
|
||||
ChoisirCouleurDessin(text);
|
||||
|
||||
snprintf(buf,100,"TEMPS : %02d:%02d",minutes,secondes);
|
||||
snprintf(buff,100,"SCORE : %07ld",*score);
|
||||
EcrireTexte(60,650,buf,2);
|
||||
EcrireTexte(600,650,buff,2);
|
||||
EcrireTexte(60,675,buf,2);
|
||||
EcrireTexte(600,675,buff,2);
|
||||
|
||||
CopierZone(1,0,0,0,930,710,0,0);
|
||||
}
|
||||
|
||||
@@ -42,8 +36,7 @@ void InitialiserPastilles(PIXELS *pastilles, PIXELS *serpent, int longueur_serpe
|
||||
|
||||
for (i = 0; i < PASTILLES; i++) {
|
||||
pastilles[i] = gen_pastille(serpent,pastilles,longueur_serpent);
|
||||
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
|
||||
|
||||
ChargerImage("./images/PommePastille.png",pastilles[i].x,pastilles[i].y,0,0,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +63,7 @@ int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int l
|
||||
if(serpent[0].x == pastilles[i].x && serpent[0].y == pastilles[i].y)
|
||||
{
|
||||
pastilles[i] = gen_pastille(serpent,pastilles,longueur_serpent);
|
||||
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
|
||||
ChargerImage("./images/PommePastille.png",pastilles[i].x,pastilles[i].y,0,0,T_PIXEL,T_PIXEL);
|
||||
*score+=5;
|
||||
return 1;
|
||||
}
|
||||
@@ -93,6 +86,7 @@ int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int l
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
|
||||
{
|
||||
int tempX = serpent[0].x;
|
||||
@@ -102,7 +96,7 @@ void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
|
||||
couleur j;
|
||||
ChoisirEcran(2);
|
||||
j=CouleurParNom("yellow");
|
||||
g=CouleurParNom("lightgreen");
|
||||
g=CouleurParComposante(171, 204, 104);
|
||||
|
||||
|
||||
for (i = 1; i < longueur; i++) {
|
||||
@@ -114,32 +108,34 @@ void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
|
||||
|
||||
tempX = tempX2;
|
||||
tempY = tempY2;
|
||||
|
||||
if(i == longueur-1)
|
||||
{
|
||||
ChoisirCouleurDessin(g);
|
||||
RemplirRectangle(serpent[i].x,serpent[i].y,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
}
|
||||
ChoisirCouleurDessin(g);
|
||||
|
||||
RemplirRectangle(serpent[longueur-1].x,serpent[longueur-1].y,T_PIXEL,T_PIXEL);
|
||||
|
||||
|
||||
ChoisirCouleurDessin(j);
|
||||
if(direction == 0) /* Direction vers la gauche */
|
||||
{
|
||||
serpent[0].x-=T_PIXEL;
|
||||
RemplirRectangle(serpent[0].x,serpent[0].y,T_PIXEL,T_PIXEL);
|
||||
ChargerImage("./images/SnakePart.png",serpent[0].x,serpent[0].y,0,0,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
else if(direction == 1) /* Direction vers le haut */
|
||||
{
|
||||
serpent[0].y-=T_PIXEL;
|
||||
RemplirRectangle(serpent[0].x,serpent[0].y,T_PIXEL,T_PIXEL);
|
||||
ChargerImage("./images/SnakePart.png",serpent[0].x,serpent[0].y,0,0,T_PIXEL,T_PIXEL);
|
||||
|
||||
}
|
||||
else if(direction == 2) /* Direction vers la droite */
|
||||
{
|
||||
serpent[0].x+=T_PIXEL;
|
||||
RemplirRectangle(serpent[0].x,serpent[0].y,T_PIXEL,T_PIXEL);
|
||||
ChargerImage("./images/SnakePart.png",serpent[0].x,serpent[0].y,0,0,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
else if(direction == 3) /* Direction vers le bas */
|
||||
{
|
||||
serpent[0].y+=T_PIXEL;
|
||||
RemplirRectangle(serpent[0].x,serpent[0].y,T_PIXEL,T_PIXEL);
|
||||
ChargerImage("./images/SnakePart.png",serpent[0].x,serpent[0].y,0,0,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user