Fix generation pastilles sur le serpent

This commit is contained in:
2023-12-12 17:29:02 +01:00
parent 15a99a4583
commit f83e28683d
7 changed files with 31 additions and 20 deletions

View File

@@ -22,7 +22,7 @@ void AfficherTimerEtScore(int m,int n,int score) /*Afficher le temps passé et
CopierZone(1,0,0,0,930,710,0,0);
}
void InitialiserPastilles(PIXELS *pastilles) {
void InitialiserPastilles(PIXELS *pastilles, PIXELS *serpent, int longueur_serpent) {
int i;
couleur r;
@@ -32,25 +32,24 @@ void InitialiserPastilles(PIXELS *pastilles) {
srand(time(NULL));
for (i = 0; i < PASTILLES; i++) {
pastilles[i] = gen_pastille();
pastilles[i] = gen_pastille(serpent,longueur_serpent);
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
}
}
int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score)
int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int longueur_serpent)
{
couleur r;
int i = 0;
int j = 0;
r = CouleurParNom("red");
ChoisirCouleurDessin(r);
for(i=0;i<PASTILLES;i++)
{
if(serpent[0].x == pastilles[i].x && serpent[0].y == pastilles[i].y)
{
pastilles[i] = gen_pastille();
pastilles[i] = gen_pastille(serpent,longueur_serpent);
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
*score+=5;
return 1;