Skip to content
Snippets Groups Projects
Commit 591f4834 authored by remi.greub's avatar remi.greub
Browse files

amélioration utilisation de structure globale pour la gestion du puissance4

parent 13d6c594
Branches
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment