Rectification Segmentation Fault du dernier commit (Agrandissement serpent + score)

This commit is contained in:
Vincent
2023-12-09 09:04:42 +01:00
parent c9155cdd88
commit 16054ef43f
3 changed files with 15 additions and 16 deletions

View File

@@ -38,7 +38,7 @@ void InitialiserPastilles(PIXELS *pastilles) {
}
}
void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, size_t longueur_pastilles,unsigned long *score)
int MangerPastille(int *serpent, PIXELS* pastilles,unsigned long *score)
{
couleur r;
int i = 0;
@@ -50,19 +50,18 @@ void MangerPastille(int *serpent, PIXELS* pastilles, size_t *longueur_serpent, s
{
if(serpent[0] == pastilles[i].x && serpent[1] == pastilles[i].y)
{
printf("\nMANGER !\n");
pastilles[i] = gen_pastille();
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*/
*score+=5;
printf("%ld",*longueur_serpent); /*voir la taille du serpent*/
return 1;
}
}
return 0;
}
int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent)
/*int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent)
{
int i;
@@ -74,7 +73,7 @@ int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent)
}
}
return 0;
}
}*/
void DeplacementSerpent(int direction ,int *serpent, int longueur)
{
@@ -105,13 +104,13 @@ void DeplacementSerpent(int direction ,int *serpent, int longueur)
if(direction == 0) /* Direction vers la gauche */
{
serpent[0]-=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
}
else if(direction == 1) /* Direction vers le haut */
{
serpent[1]-=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
}
else if(direction == 2) /* Direction vers la droite */
{