From a004b66a33412dcc9e49ea169d08116a428374e3 Mon Sep 17 00:00:00 2001 From: David Moeller Date: Fri, 26 Jan 2024 20:22:53 +0100 Subject: [PATCH] Minesweeper is playable --- src/main/c/Minesweeper/minesweeper_start.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index 98eb0eb..48bf4d9 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -88,7 +88,12 @@ void game_minesweeper(){ getchar(); 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 == 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 == 2){break;} @@ -201,7 +206,7 @@ void draw_minesweeper(Minesweeper_Board board){ int open_tile(Minesweeper_Board *board, int tile){ if(bomb_in_array(board->bombs, tile, board->num_bombs)){return -1;} int num = number_of_bombs(board, tile); - + if(1){return num;} } int number_of_bombs(Minesweeper_Board *board, int tile){