diff --git a/graphique/fenetre.c b/graphique/fenetre.c deleted file mode 100644 index 155af0a..0000000 --- a/graphique/fenetre.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Affichage de la fenêtre de jeu avec plateau de jeu, temps écoulé, score, actions des touches - - written by Yann KERAUDREN and Titouan LERICHE */ - - -#include <stdlib.h> -#include <graph.h> -#include "/export/home/an23/keraudre/DEV/SAE11_2023/prog/plateau_init.c" - - -int main (void) { - - couleur green, grey, yellow, red, black; - - int** tableau = plateau_init(); - - int i, j; - - - InitialiserGraphique(); - CreerFenetre(10,10,1450,840); - - - /* remplisage du fond d'écran */ - - grey = CouleurParComposante(35,35,35); - ChoisirCouleurDessin(grey); - RemplirRectangle(0,0,1450,840); - - /* affichage des contours */ - black = CouleurParComposante(0,0,0); - ChoisirCouleurDessin(black); - RemplirRectangle( 17, 17, 1206, 3); - - RemplirRectangle( 17, 17, 3, 806); - - RemplirRectangle( 17, 820, 1206, 3); - - RemplirRectangle( 1220, 17, 3, 806); - - - /* remplissage du plateau de jeux avec les couleur adéquate */ - - - for (i = 0; i < LIGNES; i++) { - for (j = 0; j < COLONNES; j++) { - - if ( tableau[i][j] == 0) { - - green = CouleurParComposante(50,205,50); - ChoisirCouleurDessin(green); - RemplirRectangle(20*(j+1),20*(i+1),20,20); - - } - if ( tableau[i][j] == 1) { - - yellow = CouleurParComposante(255,255,0); - ChoisirCouleurDessin(yellow); - RemplirRectangle(20*(j+1),20*(i+1),20,20); - - } - - if ( tableau[i][j] == 2) { - - red = CouleurParComposante(255,0,0); - ChoisirCouleurDessin(red); - RemplirRectangle(20*(j+1),20*(i+1),20,20); - } - - } - } - - - - /* déallocation du tableau */ - - for ( i = 0; i < LIGNES; i++) { - - free(tableau[i]); - - } - free(tableau); - - - - - - Touche(); - FermerGraphique(); - - - - return EXIT_SUCCESS; - -} diff --git a/prog/plateau_init.c b/prog/plateau_init.c deleted file mode 100644 index ba8b75a..0000000 --- a/prog/plateau_init.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Création du plateau de jeu avec les pastilles et le serpent - - written by Yann KERAUDREN and Titouan LERICHE*/ - - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> -#define LIGNES 40 -#define COLONNES 60 -#define NBR_POMME 5 -#define TAILLE_SERPENT 10 - -int** plateau_init(void) { - - int ligne_pomme, colonne_pomme, i; - - int** tableau = NULL; - - - srand(time(NULL)); - - - /* allocation du tableau dans le tas */ - - tableau = calloc(LIGNES, sizeof(double)); - - for ( i = 0; i < LIGNES; i++) { - - tableau[i] = calloc(COLONNES, sizeof(int)); - - } - - - /* positionnement du serpent */ - - for (i = 0; i < TAILLE_SERPENT; i++) { - - tableau[((LIGNES/2)-5)+i][COLONNES/2] = 1; - - } - - - - - /* positionnement alétoire des pommes */ - - for ( i = 0; i < NBR_POMME; i++) { - - - ligne_pomme = rand() % 40; - colonne_pomme = rand() % 60; - - - /* teste pour faire apparaitre exactement 5 pommes */ - - while (tableau[ligne_pomme][colonne_pomme] == 2) { - - ligne_pomme = rand() % 40; - colonne_pomme = rand() % 60; - - } - - - /* le chiffre "2" definit une pomme */ - - tableau[ligne_pomme][colonne_pomme] = 2; - - } - - - - - - return tableau; -} diff --git a/snake/Makefile b/snake/Makefile index e1ffbad..7d1c926 100755 --- a/snake/Makefile +++ b/snake/Makefile @@ -1,10 +1,10 @@ #Snake : fichier Makefile -#BUT FINAL +### BUT FINAL ### but : snake -#VARIABLES +### VARIABLES ### OFILES = plateau_init.o \ fenetre.o \ @@ -14,7 +14,7 @@ CC = gcc CFLAGS = -ansi - pedantic -lgraph -#DEPENDANCES (REGLES IMPLICITES) +### REGLES ESSENTIELLES ### plateau_init.o : plateau_init.h @@ -23,4 +23,10 @@ fenetre.o : fenetre.h plateau_init.h main.o : fenetre.h -#DEPENDANCES AVEC COMMANDES +snake : $(OFILES) + $(CC) $(CFLAGS) -o snake $(OFLIES) + +clean : -rm -f $(OFLIES) snake + + +### FIN ### diff --git a/snake/fenetre.c b/snake/fenetre.c index 3de3da6..3846a4d 100755 --- a/snake/fenetre.c +++ b/snake/fenetre.c @@ -18,9 +18,6 @@ int main (void) { InitialiserGraphique(); - - /*dimenion fenêtre*/ - CreerFenetre(10,10,1450,840); @@ -42,16 +39,6 @@ int main (void) { RemplirRectangle( 1220, 17, 3, 806); - - /*affichage du score */ - - RemplirRectangle( 1240, 17, 190, 3); - RemplirRectangle( 1240, 17, 3, 806); - RemplirRectangle( 1240, 820, 190, 3);/* - RemplirRectangle( 1230, 806, 806, 3);*/ - - - /* remplissage du plateau de jeux avec les couleur adéquate */ @@ -85,7 +72,7 @@ int main (void) { - /* désallocation du tableau */ + /* déallocation du tableau */ for ( i = 0; i < LIGNES; i++) { diff --git a/prog/snake.c b/snake/main.c similarity index 50% rename from prog/snake.c rename to snake/main.c index 4e24269..e538185 100644 --- a/prog/snake.c +++ b/snake/main.c @@ -1,8 +1,10 @@ #include <stdlib.h> #include <stdio.h> +#include "fenetre.h" +#include "plateau_init.h" -int main (void) { +int main(void) { return EXIT_SUCCESS; } diff --git a/snake/plateau_init.c b/snake/plateau_init.c index ba8b75a..7dc25ec 100755 --- a/snake/plateau_init.c +++ b/snake/plateau_init.c @@ -54,7 +54,7 @@ int** plateau_init(void) { /* teste pour faire apparaitre exactement 5 pommes */ - while (tableau[ligne_pomme][colonne_pomme] == 2) { + while (tableau[ligne_pomme][colonne_pomme] == 2 || tableau[ligne_pomme][colonne_pomme] == 1) { ligne_pomme = rand() % 40; colonne_pomme = rand() % 60;