From 2783bc984b32b95187d165207cf94ae4f05873e3 Mon Sep 17 00:00:00 2001 From: keraudre Date: Sat, 25 Nov 2023 20:33:18 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9solution=20du=20probl=C3=A8me=20li=C3=A9?= =?UTF-8?q?e=20au=20tableau=20et=20fin=20de=20l'affichage=20du=20plateau?= =?UTF-8?q?=20initiale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphique/fenetre.c | 47 +++++++++++++++++++++------------------------ prog/plateau_init.c | 7 ++++--- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/graphique/fenetre.c b/graphique/fenetre.c index a80c373..399a393 100644 --- a/graphique/fenetre.c +++ b/graphique/fenetre.c @@ -1,11 +1,11 @@ #include #include -#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) { - couleur green, white, yellow, red; + couleur green, grey, yellow, red, black; int** tableau = plateau_init(); @@ -13,18 +13,25 @@ int main (void) { 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 */ - white = CouleurParComposante(255,255,255); - ChoisirCouleurDessin(white); - RemplirRectangle(0,0,1550,910); + grey = CouleurParComposante(35,35,35); + ChoisirCouleurDessin(grey); + 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 */ @@ -35,16 +42,16 @@ int main (void) { if ( tableau[i][j] == 0) { - green = CouleurParComposante(0,255,30); + green = CouleurParComposante(50,205,50); 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) { yellow = CouleurParComposante(255,255,0); 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); 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++) { free(tableau[i]); - } + } free(tableau); diff --git a/prog/plateau_init.c b/prog/plateau_init.c index 9c099ee..ba8b75a 100644 --- a/prog/plateau_init.c +++ b/prog/plateau_init.c @@ -15,7 +15,7 @@ int** plateau_init(void) { int ligne_pomme, colonne_pomme, i; - int ** tableau = NULL; + int** tableau = NULL; srand(time(NULL)); @@ -23,7 +23,7 @@ int** plateau_init(void) { /* allocation du tableau dans le tas */ - tableau = calloc(LIGNES, sizeof(int)); + tableau = calloc(LIGNES, sizeof(double)); for ( i = 0; i < LIGNES; i++) { @@ -67,8 +67,9 @@ int** plateau_init(void) { tableau[ligne_pomme][colonne_pomme] = 2; } - + + return tableau;