Browse Source

Minesweeper is playable

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

9
src/main/c/Minesweeper/minesweeper_start.c

@ -88,7 +88,12 @@ void game_minesweeper(){
getchar(); getchar();
if(x < board.width && x > -1 && y < board.height && y > -1){ if(x < board.width && x > -1 && y < board.height && y > -1){
x = x + y * board.width; x = x + y * board.width;
if(t == 0){running = open_tile(&board, x);}
if(t == 0){
int bombs = open_tile(&board, x);
if(bombs == -1){running = false;}
else if(bombs == 0){board.tiles[x] = EMPTY;}
else{board.tiles[x] = bombs + 48;}
}
if(t == 1){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];} if(t == 1){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];}
} }
if (t == 2){break;} if (t == 2){break;}
@ -201,7 +206,7 @@ void draw_minesweeper(Minesweeper_Board board){
int open_tile(Minesweeper_Board *board, int tile){ int open_tile(Minesweeper_Board *board, int tile){
if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;} if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;}
int num = number_of_bombs(board, tile); int num = number_of_bombs(board, tile);
if(1){return num;}
} }
int number_of_bombs(Minesweeper_Board *board, int tile){ int number_of_bombs(Minesweeper_Board *board, int tile){

Loading…
Cancel
Save