diff --git a/snake/augmentation_serpent.c b/snake/augmentation_serpent.c index 3f2ad0d..b67fe2c 100644 --- a/snake/augmentation_serpent.c +++ b/snake/augmentation_serpent.c @@ -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]; } diff --git a/snake/jeu-snake.jpeg b/snake/jeu-snake.jpeg deleted file mode 100644 index 3f8732e..0000000 Binary files a/snake/jeu-snake.jpeg and /dev/null differ diff --git a/snake/lancement b/snake/lancement new file mode 100755 index 0000000..f1822e7 Binary files /dev/null and b/snake/lancement differ diff --git a/snake/supp_queue.c b/snake/supp_queue.c index 0c3d7a9..3c9465b 100644 --- a/snake/supp_queue.c +++ b/snake/supp_queue.c @@ -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); + }