|
|
@ -24,6 +24,7 @@ Minesweeper_Board initialize_minesweeper(); |
|
|
|
void place_bombs(Minesweeper_Board *board); |
|
|
|
bool bomb_in_array(int array[], int bomb, int length); |
|
|
|
void draw_minesweeper(Minesweeper_Board board); |
|
|
|
int open_tile(Minesweeper_Board *board, int tile); |
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
#pragma region Global |
|
|
@ -84,8 +85,9 @@ void game_minesweeper(){ |
|
|
|
printf("Next turn (x, y, t(0 = open, 1 = flag)): "); |
|
|
|
scanf("%d %d %d", &x, &y, &t); |
|
|
|
getchar(); |
|
|
|
if(x < board.width && y < board.height){ |
|
|
|
if(x < board.width && x > -1 && y < board.height && y > -1){ |
|
|
|
x = x + y * board.width; |
|
|
|
if(t == 0){running = open_tile(&board, x);} |
|
|
|
if(t == 1){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];} |
|
|
|
} |
|
|
|
if (t == 2){break;} |
|
|
@ -193,4 +195,9 @@ void draw_minesweeper(Minesweeper_Board board){ |
|
|
|
printf(" +"); |
|
|
|
for(int i = 0; i < board.width; i++){printf("-");} |
|
|
|
printf("+\n"); |
|
|
|
} |
|
|
|
|
|
|
|
int open_tile(Minesweeper_Board *board, int tile){ |
|
|
|
if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;} |
|
|
|
|
|
|
|
} |