résolution du problème liée au tableau et fin de l'affichage du plateau initiale

This commit is contained in:
2023-11-25 20:33:18 +01:00
parent dc9ba3e4fe
commit 2783bc984b
2 changed files with 26 additions and 28 deletions

View File

@@ -1,11 +1,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <graph.h> #include <graph.h>
#include "/export/home/an23/keraudre/SAE11_2023/prog/plateau_init.c" #include "/export/home/an23/keraudre/DEV/SAE11_2023/prog/plateau_init.c"
int main (void) { int main (void) {
couleur green, white, yellow, red; couleur green, grey, yellow, red, black;
int** tableau = plateau_init(); int** tableau = plateau_init();
@@ -13,18 +13,25 @@ int main (void) {
InitialiserGraphique(); InitialiserGraphique();
CreerFenetre(10,10,1550,910); CreerFenetre(10,10,1450,840);
/* tracer du plateau de jeux*/
DessinerRectangle(15,15,1320,880);
/* remplisage du fond d'écran */ /* remplisage du fond d'écran */
white = CouleurParComposante(255,255,255); grey = CouleurParComposante(35,35,35);
ChoisirCouleurDessin(white); ChoisirCouleurDessin(grey);
RemplirRectangle(0,0,1550,910); RemplirRectangle(0,0,1450,840);
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 */ /* remplissage du plateau de jeux avec les couleur adéquate */
@@ -35,16 +42,16 @@ int main (void) {
if ( tableau[i][j] == 0) { if ( tableau[i][j] == 0) {
green = CouleurParComposante(0,255,30); green = CouleurParComposante(50,205,50);
ChoisirCouleurDessin(green); ChoisirCouleurDessin(green);
RemplirRectangle(15*(j+1),15*(i+1),22,20); RemplirRectangle(20*(j+1),20*(i+1),20,20);
} }
if ( tableau[i][j] == 1) { if ( tableau[i][j] == 1) {
yellow = CouleurParComposante(255,255,0); yellow = CouleurParComposante(255,255,0);
ChoisirCouleurDessin(yellow); ChoisirCouleurDessin(yellow);
RemplirRectangle(15*(j+1),15*(i+1),22,20); RemplirRectangle(20*(j+1),20*(i+1),20,20);
} }
@@ -52,31 +59,21 @@ int main (void) {
red = CouleurParComposante(255,0,0); red = CouleurParComposante(255,0,0);
ChoisirCouleurDessin(red); ChoisirCouleurDessin(red);
RemplirRectangle(15*(j+1),15*(i+1),22,20); RemplirRectangle(20*(j+1),20*(i+1),20,20);
} }
} }
} }
for ( i = 0; i < LIGNES; i++) {
for ( j = 0; j < COLONNES; j++) {
printf("%d", tableau[i][j]);
}
printf("\n");
}
printf("\n");
/* déallocation du tableau */
for ( i = 0; i < LIGNES; i++) { for ( i = 0; i < LIGNES; i++) {
free(tableau[i]); free(tableau[i]);
}
}
free(tableau); free(tableau);

View File

@@ -15,7 +15,7 @@ int** plateau_init(void) {
int ligne_pomme, colonne_pomme, i; int ligne_pomme, colonne_pomme, i;
int ** tableau = NULL; int** tableau = NULL;
srand(time(NULL)); srand(time(NULL));
@@ -23,7 +23,7 @@ int** plateau_init(void) {
/* allocation du tableau dans le tas */ /* allocation du tableau dans le tas */
tableau = calloc(LIGNES, sizeof(int)); tableau = calloc(LIGNES, sizeof(double));
for ( i = 0; i < LIGNES; i++) { for ( i = 0; i < LIGNES; i++) {
@@ -67,8 +67,9 @@ int** plateau_init(void) {
tableau[ligne_pomme][colonne_pomme] = 2; tableau[ligne_pomme][colonne_pomme] = 2;
} }
return tableau; return tableau;