fin de la fonction qui agrandie le serpent lorqu'il mange une pomme
This commit is contained in:
@@ -27,37 +27,45 @@ void augmentation_serpent (struct adresse* pointeur) {
|
||||
|
||||
|
||||
/* augmentation de la taille du serpent */
|
||||
|
||||
|
||||
*taille_serpent = *taille_serpent + 1;
|
||||
|
||||
|
||||
|
||||
|
||||
/* création d'un nouveau tableau */
|
||||
|
||||
corps_serpent2 = malloc( *taille_serpent * sizeof(int*));
|
||||
|
||||
for ( i = 0; i < *taille_serpent; i++) {
|
||||
|
||||
corps_serpent2 = malloc( 2 * sizeof(int));
|
||||
corps_serpent2[i] = malloc( 2 * sizeof(int));
|
||||
|
||||
}
|
||||
|
||||
printf("%hu\n", *taille_serpent);
|
||||
|
||||
|
||||
|
||||
/* attributions des anciennes cases du corps dans le nouveau tableau et ajout de la nouvelle tête au bonne endroit*/
|
||||
|
||||
for ( i = 0 ; i < *indice_queue; i++) {
|
||||
|
||||
corps_serpent2[i] = corps_serpent[i] ;
|
||||
corps_serpent2[i][0]= corps_serpent[i][0] ;
|
||||
corps_serpent2[i][1]= corps_serpent[i][1] ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
corps_serpent2[*indice_queue][0] = tete[0];
|
||||
corps_serpent2[*indice_queue][1] = tete[1];
|
||||
|
||||
|
||||
for ( i = *indice_queue; i < *taille_serpent - 1; i++) {
|
||||
for ( i = *indice_queue ; i < *taille_serpent - 1; i++) {
|
||||
|
||||
corps_serpent2[i+1] = corps_serpent[i];
|
||||
corps_serpent2[i+1][0] = corps_serpent[i][0];
|
||||
corps_serpent2[i+1][1] = corps_serpent[i][1];
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user