Browse Source

refactoring: open_tile and draw_minesweeper

remotes/origin/David
David Moeller 11 months ago
parent
commit
1b6ffe72d9
  1. 6
      src/main/c/Minesweeper/minesweeper_start.c

6
src/main/c/Minesweeper/minesweeper_start.c

@ -189,6 +189,9 @@ bool array_contains_value(int *array, int value, int length){
} }
void draw_minesweeper(Minesweeper_Board *board){ void draw_minesweeper(Minesweeper_Board *board){
int s = 0;
for(int i = 0; i < board->height * board->width; i++){s += board->tiles[i] == FLAG ? 1 : 0;}
printf("Score: %d\n", s);
printf(" "); printf(" ");
for(int i = 0; i < board->width; i++){printf("%d", i / 10);} for(int i = 0; i < board->width; i++){printf("%d", i / 10);}
printf("\n "); printf("\n ");
@ -214,8 +217,7 @@ void draw_minesweeper(Minesweeper_Board *board){
int open_tile(Minesweeper_Board *board, int tile){ int open_tile(Minesweeper_Board *board, int tile){
if(array_contains_value(board->bombs, tile, board->num_bombs)){return -1;} if(array_contains_value(board->bombs, tile, board->num_bombs)){return -1;}
int num = number_of_bombs(board, tile);
if(1){return num;}
return number_of_bombs(board, tile);
} }
int number_of_bombs(Minesweeper_Board *board, int tile){ int number_of_bombs(Minesweeper_Board *board, int tile){

Loading…
Cancel
Save