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

ajout gestion affichage

parent 545b5540
Branches
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ int main(int argc, char** argv){
}
init_puissance4(height, width);
//print_game();
//print_gameCells();
int win = Launch_puissance4();
printf("\nle winner c'est ça la : %d\n",win);
......@@ -29,5 +30,4 @@ int main(int argc, char** argv){
// dessine une quadrillage puissance4.h
// créé un quadrillage virtuel puissance4.h
// trouve qui a gagner puissance4.h
\ No newline at end of file
// trouve qui a gagner puissance4.h
\ No newline at end of file
......@@ -106,7 +106,8 @@ int Launch_puissance4(){
while(winner==EMPTY){
//print_grille();
print_gameCells();
//print_gameCells();
print_game();
printf("au tour de %d de jouer\n", game.curr_player);
printf("balance un chiffre entre 0 et %d\n", game.width-1);
do{
......@@ -131,7 +132,8 @@ int Launch_puissance4(){
//il y a un bug de zinzin
printf("ok la y a un bug de zinzin check ca \n");
//print la grille pour debug
print_gameCells();
//print_gameCells();
print_game();
//fin du jeu
return -1; //erreur
}
......@@ -141,7 +143,8 @@ int Launch_puissance4(){
if( winner != EMPTY){
if(winner==CROSS){
//reset du jeu + mise a jour des scores (scores optionels)
print_gameCells();
//print_gameCells();
print_game();
printf("la croix a gagnée cette connasse\n");
//print joueur croix a gagné
//fin du jeu
......@@ -150,7 +153,8 @@ int Launch_puissance4(){
if(winner==CIRCLE){
//reset du jeu + mise a jour des scores (scores optionels)
//print joueur cercle a gagné
print_gameCells();
//print_gameCells();
print_game();
printf("le cercle a gagné cet enorme zgeg\n");
//fin du jeu
return CIRCLE;
......@@ -160,7 +164,8 @@ int Launch_puissance4(){
if(Is_Grid_full()){
//la grille est pleine
//print egalite + la fin de la grille
print_gameCells();
//print_gameCells();
print_game();
printf("y a un egalite dans les regles de l'art mash'allah\n");
//winner = EQUAL;
//fin du jeu
......@@ -253,4 +258,92 @@ symbol_t CheckWin_in_a_direction(int dir[2], struct cell **grid, struct cell cel
}
}
return result;
}
void print_game(){
printf("h:%d, w:%d\n", game.height, game.width);
//affiche ┌─┬─┬─┬─┬─┬─┬─┐
for(int i=0; i<(game.width*2)+1; i++){
if(i%2){
printf("─");
}else{
if(i==0){
printf("┌");
}
else if(i == (game.width*2)){
printf("┐");
}
else{
printf("┬");
}
}
}
printf("\n");
//affiche le jeu-> │ │ │X│O│ │ │ │
for(int i=0; i<game.height; i++){
printf("│");
for(int j=0; j<game.width; j++){
if(game.cells[j][(game.height-i)-1].symbol==EMPTY){
printf(" ");
}
else if(game.cells[j][(game.height-i)-1].symbol==CROSS){
printf("X");
}else if(game.cells[j][(game.height-i)-1].symbol==CIRCLE){
printf("O");
}else{
printf("E");
}
printf("│");
}
printf("\n");
if(i<game.height-1){
//Dessine ├─┼─┼─┼─┼─┼─┼─┤ ...
for(int cnt=0; cnt<((game.width*2)+1); cnt++){
if(cnt%2){
printf("─");
}else{
if(cnt == 0){
printf("├");
}
else if(cnt == (game.width*2)){
printf("┤");
}
else{
printf("┼");
}
}
}
printf("\n");
}
}
//Affiche └─┴─┴─┴─┴─┴─┴─┘
for(int i=0; i<(game.width*2)+1; i++){
if(i%2){
printf("─");
}else{
if(i==0){
printf("└");
}
else if(i == (game.width*2)){
printf("┘");
}
else{
printf("┴");
}
}
}
printf("\n");
//affiche les numéros
int cnt = 0;
for(int i=0; i<(game.width*2)+1; i++){
if(i%2){
printf("%d",++cnt);
}else{
printf(" ");
}
}
printf("\n");
}
\ No newline at end of file
......@@ -50,6 +50,8 @@ int is_cell_free(int j_p, int i, symbol_t symbol);
int Launch_puissance4();
bool Is_Grid_full();
void print_game();
symbol_t Find_winner(struct cell **grid, struct cell cellPlayed);
symbol_t CheckWin_in_a_direction(int dir[2], struct cell **grid, struct cell cell);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment