augmentatio ndu score lorsque pastille mangé
This commit is contained in:
parent
cdd412b3eb
commit
c9155cdd88
17
evenement.c
17
evenement.c
@ -38,7 +38,7 @@ void InitialiserPastilles(PIXELS *pastilles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, size_t longueur_pastilles)
|
void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, size_t longueur_pastilles,unsigned long *score)
|
||||||
{
|
{
|
||||||
couleur r;
|
couleur r;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -54,6 +54,7 @@ void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, s
|
|||||||
pastilles[i] = gen_pastille();
|
pastilles[i] = gen_pastille();
|
||||||
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
|
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
|
||||||
*longueur_serpent+=2;/*augmente la taille du serpent de deux car un pixel =2*/
|
*longueur_serpent+=2;/*augmente la taille du serpent de deux car un pixel =2*/
|
||||||
|
*score+=5;
|
||||||
printf("%ld",*longueur_serpent); /*voir la taille du serpent*/
|
printf("%ld",*longueur_serpent); /*voir la taille du serpent*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,6 +62,20 @@ void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, s
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0;i<longueur_serpent;i+=2)
|
||||||
|
{
|
||||||
|
if (pastille.x==serpent[i] && pastille.y ==serpent[i+1])
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void DeplacementSerpent(int direction ,int *serpent, int longueur)
|
void DeplacementSerpent(int direction ,int *serpent, int longueur)
|
||||||
{
|
{
|
||||||
int tempX = serpent[0];
|
int tempX = serpent[0];
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#ifndef EVENEMENT_H
|
#ifndef EVENEMENT_H
|
||||||
#define EVENEMENT_H
|
#define EVENEMENT_H
|
||||||
|
|
||||||
void MangerPastille(int *serpent, PIXELS* pastilles, size_t longueur_serpent, size_t longueur_pastilles);
|
void MangerPastille(int *serpent, PIXELS* pastilles, size_t longueur_serpent, size_t longueur_pastilles, unsigned long *score);
|
||||||
|
|
||||||
void DeplacementSerpent(int direction ,int *serpent, int longueur);
|
void DeplacementSerpent(int direction ,int *serpent, int longueur);
|
||||||
|
|
||||||
@ -11,4 +11,6 @@ void InitialiserPastilles(PIXELS *pastilles);
|
|||||||
|
|
||||||
void AfficherTimerEtScore(int m,int n,int score);
|
void AfficherTimerEtScore(int m,int n,int score);
|
||||||
|
|
||||||
|
int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent);
|
||||||
|
|
||||||
#endif
|
#endif
|
BIN
evenement.o
BIN
evenement.o
Binary file not shown.
6
main.c
6
main.c
@ -27,7 +27,7 @@ PIXELS gen_pastille()
|
|||||||
{
|
{
|
||||||
int x_pastille,y_pastille;
|
int x_pastille,y_pastille;
|
||||||
PIXELS pastille;
|
PIXELS pastille;
|
||||||
|
|
||||||
x_pastille= ArrondirPixel(rand()%W_GAME);
|
x_pastille= ArrondirPixel(rand()%W_GAME);
|
||||||
y_pastille = ArrondirPixel(rand()%H_GAME);
|
y_pastille = ArrondirPixel(rand()%H_GAME);
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ void DessinerScene(PIXELS *pastilles, int *serpent) /* Dessine la scène */
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
unsigned char pause = 0;
|
unsigned char pause = 0;
|
||||||
int score =0;
|
unsigned long *score =0;
|
||||||
unsigned long suivant;
|
unsigned long suivant;
|
||||||
int go_on=1;
|
int go_on=1;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -194,7 +194,7 @@ int main()
|
|||||||
direction_davant = direction; /* Check si le serpent à le droit de changer de direction */
|
direction_davant = direction; /* Check si le serpent à le droit de changer de direction */
|
||||||
|
|
||||||
DeplacementSerpent(direction,serpent,longueur_serpent);
|
DeplacementSerpent(direction,serpent,longueur_serpent);
|
||||||
MangerPastille(serpent,pastilles,&longueur_serpent,longueur_pastilles);
|
MangerPastille(serpent,pastilles,&longueur_serpent,longueur_pastilles,&score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
main.o
BIN
main.o
Binary file not shown.
BIN
prog
BIN
prog
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user