Réorganisation des fichiers et création du fichier Makefile
This commit is contained in:
parent
9f64e553ce
commit
a7e9587cbc
@ -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;
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
@ -1,10 +1,10 @@
|
|||||||
#Snake : fichier Makefile
|
#Snake : fichier Makefile
|
||||||
|
|
||||||
#BUT FINAL
|
### BUT FINAL ###
|
||||||
|
|
||||||
but : snake
|
but : snake
|
||||||
|
|
||||||
#VARIABLES
|
### VARIABLES ###
|
||||||
|
|
||||||
OFILES = plateau_init.o \
|
OFILES = plateau_init.o \
|
||||||
fenetre.o \
|
fenetre.o \
|
||||||
@ -14,7 +14,7 @@ CC = gcc
|
|||||||
|
|
||||||
CFLAGS = -ansi - pedantic -lgraph
|
CFLAGS = -ansi - pedantic -lgraph
|
||||||
|
|
||||||
#DEPENDANCES (REGLES IMPLICITES)
|
### REGLES ESSENTIELLES ###
|
||||||
|
|
||||||
plateau_init.o : plateau_init.h
|
plateau_init.o : plateau_init.h
|
||||||
|
|
||||||
@ -23,4 +23,10 @@ fenetre.o : fenetre.h plateau_init.h
|
|||||||
main.o : fenetre.h
|
main.o : fenetre.h
|
||||||
|
|
||||||
|
|
||||||
#DEPENDANCES AVEC COMMANDES
|
snake : $(OFILES)
|
||||||
|
$(CC) $(CFLAGS) -o snake $(OFLIES)
|
||||||
|
|
||||||
|
clean : -rm -f $(OFLIES) snake
|
||||||
|
|
||||||
|
|
||||||
|
### FIN ###
|
||||||
|
@ -18,9 +18,6 @@ int main (void) {
|
|||||||
|
|
||||||
|
|
||||||
InitialiserGraphique();
|
InitialiserGraphique();
|
||||||
|
|
||||||
/*dimenion fenêtre*/
|
|
||||||
|
|
||||||
CreerFenetre(10,10,1450,840);
|
CreerFenetre(10,10,1450,840);
|
||||||
|
|
||||||
|
|
||||||
@ -42,16 +39,6 @@ int main (void) {
|
|||||||
RemplirRectangle( 1220, 17, 3, 806);
|
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 */
|
/* 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++) {
|
for ( i = 0; i < LIGNES; i++) {
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "fenetre.h"
|
||||||
|
#include "plateau_init.h"
|
||||||
|
|
||||||
|
|
||||||
int main (void) {
|
int main(void) {
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ int** plateau_init(void) {
|
|||||||
|
|
||||||
/* teste pour faire apparaitre exactement 5 pommes */
|
/* 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;
|
ligne_pomme = rand() % 40;
|
||||||
colonne_pomme = rand() % 60;
|
colonne_pomme = rand() % 60;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user