diff --git a/puissance4_GRB/puissance4.c b/puissance4_GRB/puissance4.c index b15968f16df21d1662984b24431dde344d4d1eb8..e0a5a958660a9beed585c716c8c8b85a15babe26 100644 --- a/puissance4_GRB/puissance4.c +++ b/puissance4_GRB/puissance4.c @@ -2,22 +2,24 @@ #include <stdint.h> #include <stdio.h> +grid game; + /*********************************** * function : Create_grid2D - * arguments : taille de grille (ex: 3 pour 3x3) + * arguments : taille de grille hauteur x largeur * * return value : cell_t** -> la grille mise à jour et allouée * initialise les valeurs de la grille * et alloue la mémoire dynamiquement ***********************************/ -struct cell **Create_grid2D(uint8_t height, uint8_t width){ - struct cell** cells = malloc(height*sizeof(struct cell)); - for(int k =0; k<height; k++){ - cells[k] = malloc(width*sizeof(struct cell)); +struct cell **Create_grid2D(){ + struct cell** cells = malloc(game.height*sizeof(struct cell*)); + for(int k =0; k<game.height; k++){ + cells[k] = malloc(game.width*sizeof(struct cell)); } //initialise les positions et les valeurs de base - for(int i = 0; i<height; i++){ - for(int j=0; j<width; j++){ + for(int i = 0; i<game.height; i++){ + for(int j=0; j<game.width; j++){ cells[i][j].pressed = false; cells[i][j].symbol = EMPTY; cells[i][j].i_pos = i;