fin de la fonction qui agrandie le serpent lorqu'il mange une pomme
This commit is contained in:
parent
e726ecd02b
commit
3b0599777b
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before ![]() (image error) Size: 48 KiB |
BIN
snake/lancement
Executable file
BIN
snake/lancement
Executable file
Binary file not shown.
@ -44,21 +44,9 @@ void supp_queue( struct adresse* pointeur, unsigned char* retard ) {
|
||||
|
||||
*retard = *retard + 2;
|
||||
|
||||
printf("[%hhu]\n", *retard);
|
||||
|
||||
if (*retard >0 ) {
|
||||
|
||||
augmentation_serpent(pointeur);
|
||||
|
||||
*retard = *retard - 1;
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
|
||||
/* apparition de la nouvelle pomme */
|
||||
|
||||
/* apparition de la nouvelle pomme */
|
||||
|
||||
ligne_pomme = rand() % 40;
|
||||
colonne_pomme = rand() % 60;
|
||||
@ -77,8 +65,20 @@ void supp_queue( struct adresse* pointeur, unsigned char* retard ) {
|
||||
ChoisirCouleurDessin(red);
|
||||
RemplirRectangle(20*(colonne_pomme + 1),20*(ligne_pomme + 1),20,20);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (*retard >0 ) {
|
||||
|
||||
augmentation_serpent(pointeur);
|
||||
|
||||
*retard = *retard - 1;
|
||||
|
||||
printf("[%hhu]\n", *retard);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user