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 <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) {
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);

View File

@@ -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;