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

creation de grille virtuelle

parent ee3c8359
Branches
No related tags found
No related merge requests found
#include "puissance4.h"
#include <stdint.h>
#include <stdio.h>
/***********************************
* function : Create_grid2D
* arguments : taille de grille (ex: 3 pour 3x3)
*
* 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));
}
//initialise les positions et les valeurs de base
for(int i = 0; i<height; i++){
for(int j=0; j<width; j++){
cells[i][j].pressed = false;
cells[i][j].symbol = EMPTY;
cells[i][j].i_pos = i;
cells[i][j].j_pos = j;
}
}
return cells;
}
#ifndef _PUIS4_
#define _PUIS4_
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
struct grid{
int height;
int width;
struct cell** cells;
}typedef grid;
typedef enum{
CIRCLE, //signifie le symbole du cercle
CROSS, //signifie le symbole de la croix
EMPTY, //signifie une cellule vide
EQUAL //signifie un état d'égalité entre la croix et le cercle
}symbol_t;
struct cell{
bool pressed;
symbol_t symbol;
int i_pos;
int j_pos;
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment