From 8e4593aaa40e0905555c5baaa3f6d2e878ffaaa9 Mon Sep 17 00:00:00 2001 From: David Moeller Date: Mon, 5 Feb 2024 21:36:54 +0100 Subject: [PATCH] Minesweeper adding Win and Loss --- src/main/c/Minesweeper/minesweeper_start.c | 8 ++++++-- src/main/c/Snake/snake_start.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index a102944..19b4e50 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -36,7 +36,6 @@ unsigned int height = MIDDLE; int num_bombs = MIDDLE * MIDDLE / NORMAL; #pragma endregion //Global - void minesweeper_start(){ system("clear"); main_menu_minesweeper(); @@ -93,13 +92,18 @@ void game_minesweeper(){ x = x + y * board.width; if(t == 0){ int bombs = open_tile(&board, x); - if(bombs == -1){running = false;} + if(bombs == -1){printf("You Lose!"); getchar(); break;} else if(bombs == 0){open_empty_space(&board, x, 0);} 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;} + + int test = 1; + for (int i = 0; i < board.height * board.width; i++){if(board.tiles[i] == BLOCK){test = 0; break;}} + if(test){printf("You Win!"); getchar(); break;} + } } diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 03323ce..ac8690f 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -5,12 +5,15 @@ #include #include "snake_start.h" #include "get_character.h" + +#pragma region defines #define WIDTH 15 #define HEIGHT 15 #define TURN 0.5 #define START_LENGTH 3 #define START_DIRECTION 1 #define START_TILE 8 * 16 + 8 +#pragma endregion #pragma region Funktion_heads void main_menu_snake();