From a8b525a146e6fbf1a3d9b500a3187a164f3beeac Mon Sep 17 00:00:00 2001 From: David Moeller Date: Mon, 5 Feb 2024 21:07:50 +0100 Subject: [PATCH] refactoring: snake_collision --- src/main/c/Minesweeper/minesweeper_start.c | 6 +++--- src/main/c/Snake/snake_start.c | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index f9131fb..a102944 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -3,6 +3,7 @@ #include #include #include "minesweeper_start.h" + #pragma region defines #define BLOCK '#' #define FLAG 'x' @@ -15,7 +16,6 @@ #define HARD 3 #pragma endregion - #pragma region Funktion_heads void main_menu_minesweeper(); void game_minesweeper(); @@ -120,7 +120,7 @@ void options_minesweeper(){ switch (option){ case 1: - printf("Bitte neu Schwierigkeit eingeben (1 - 3): "); + printf("Bitte neue Schwierigkeit eingeben (1 - 3): "); scanf("%d", &num_bombs); getchar(); num_bombs = num_bombs == 1 ? EASY : num_bombs == 2 ? NORMAL : HARD; @@ -128,7 +128,7 @@ void options_minesweeper(){ break; case 2: num_bombs = num_bombs < width * height / NORMAL ? EASY : num_bombs == width * height / NORMAL ? NORMAL : HARD; - printf("Bitte neu Groesse eingeben (1 - 3): "); + printf("Bitte neue Groesse eingeben (1 - 3): "); scanf("%d", &width); getchar(); width = width == 1 ? SMALL : width == 2 ? MIDDLE : LARGE; diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 26c83c4..c3a0cf8 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -175,14 +175,10 @@ int part_of_snake(Snake *snake, unsigned char tile){ bool check_if_dead(Snake *snake){ //Self - if(part_of_snake(snake, snake->segments[0]) > 0){ - return true; - } + if(part_of_snake(snake, snake->segments[0])){return true;} //Wall - if(snake->segments[0] % 16 == 0 || (snake->segments[0] / 16) % 16 == 0){ - return true; - } + if(snake->segments[0] % 16 == 0 || (snake->segments[0] / 16) % 16 == 0){return true;} return false; }