diff --git a/snake/Makefile b/snake/Makefile index 8b4dd61..b92e83a 100755 --- a/snake/Makefile +++ b/snake/Makefile @@ -7,9 +7,12 @@ but : run ### VARIABLES ### OFILES = plateau_init.o \ - fenetre.o \ - deplacement.o \ - main.o + fenetre.o \ + deplacement.o \ + ajout_score.o \ + score_init.o \ + main.o + CC = gcc @@ -23,9 +26,14 @@ fenetre.o : fenetre.h plateau_init.h deplacement.o : deplacement.h +ajout_score.o : ajout_score.h + +score_init.o : score_init.h + main.o : main.c fenetre.h deplacement.h + ### COMMANDES ### diff --git a/snake/ajout_score.c b/snake/ajout_score.c index 654033d..b78bfaf 100644 --- a/snake/ajout_score.c +++ b/snake/ajout_score.c @@ -7,34 +7,6 @@ #include "ajout_score.h" -/*int main(unsigned int compteur) { - compteur = compteur + 5; - char* a= (int) compteur; - EcrireTexte(1250, 600, a, 2); -}*/ - - - - -/* -int main() { - int compteur = 10; - - compteur = compteur + 5; - - - char a[20]; - sprintf(a, "%d", compteur); - - - EcrireTexte(1250, 600, a, 2); - - return 0; -} -*/ - - - void ajout_score(int* compteur) { @@ -53,30 +25,7 @@ void ajout_score(int* compteur) { } -/* -int main() { - int compteur = 0; - char key; - - printf("Appuyez sur ESPACE pour ajouter 5 (Appuyez sur 'q' pour quitter)\n"); - - while (1) { - key = getchar(); - if (key == ' ') { - compteur += 5; - printf("Compteur : %d\n", compteur); - } else if (key == 'q' || key == 'Q') { - printf("Sortie du programme.\n"); - break; - } - } - - return 0; -} -*/ - - diff --git a/snake/lancement b/snake/lancement index 54aaf37..74a99f8 100755 Binary files a/snake/lancement and b/snake/lancement differ diff --git a/snake/main.c b/snake/main.c index 635f63c..17dbd04 100644 --- a/snake/main.c +++ b/snake/main.c @@ -14,6 +14,8 @@ int main(void) { struct adresse* pointeur = plateau_init(); + short int* compteur = NULL; + int i; @@ -24,6 +26,7 @@ int main(void) { unsigned long suivant; + sens = malloc(sizeof(unsigned char)); *sens = 2; @@ -42,8 +45,16 @@ int main(void) { + + + + + start(pointeur); + compteur = score_init(); + + Touche(); while ( jeu = 1) { if (Microsecondes() > suivant) { @@ -77,6 +88,8 @@ int main(void) { free(pointeur); + free(compteur); + diff --git a/snake/score_init.c b/snake/score_init.c index 35bee3e..b29ac2b 100644 --- a/snake/score_init.c +++ b/snake/score_init.c @@ -6,15 +6,18 @@ -void score_init(int* compteur) { +short int* score_init(void) { - int *compteur = NULL; - compteur = malloc(sizeof(int)); + short int* compteur = NULL; + compteur = malloc(sizeof(short int)); *compteur = 0; + char a[20]; + sprintf(a, "%d", *compteur); + EcrireTexte(1250, 600, a, 2); + + return compteur; +} - - free(compteur); -} \ No newline at end of file diff --git a/snake/score_init.h b/snake/score_init.h index 460d4bf..e6396c8 100644 --- a/snake/score_init.h +++ b/snake/score_init.h @@ -2,7 +2,7 @@ #define SCORE_INIT_H -void score_init (int* compteur); +short int* score_init (void); #endif /* SCORE_INIT_H */