diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index 7b28bd1..2737d4d 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -1,8 +1,16 @@ #include #include +#pragma region defines #define BLOCK 219 #define FLAG '?' #define EMPTY ' ' +#define SMALL 10 +#define MIDDLE 15 +#define LARGE 20 +#define EASY 7 +#define NORMAL 5 +#define HARD 3 +#pragma endregion #pragma region Funktion_heads @@ -12,6 +20,9 @@ void options_minesweeper(); #pragma endregion #pragma region Global +unsigned int width = MIDDLE; +unsigned int height = MIDDLE; +int num_bombs = MIDDLE * MIDDLE / NORMAL; #pragma endregion //Global @@ -58,5 +69,54 @@ void game_minesweeper(){ } void options_minesweeper(){ + bool running = true; + while (running){ + int option = 0; + + system("clear"); + printf("Waehlen Sie eine Option:\n"); + printf("\t1.Schwierigkeit\t\t%s\n", num_bombs < 2 * width * height / (NORMAL + EASY) ? "Einfach" : num_bombs < 2 * width * height / (NORMAL + HARD) ? "Normal" : "Schwer"); + printf("\t2.Groesse\t\t%s\n", width * height < MIDDLE * SMALL ? "Klein" : width * height < MIDDLE * LARGE ? "Mittel" : "Gross"); + printf("\t3.Custom\n"); + printf("\t4.Exit\n"); + + scanf("%d", &option); + getchar(); + switch (option){ + case 1: + printf("Bitte neu Schwierigkeit eingeben (1 - 3):"); + scanf("%d", &num_bombs); + getchar(); + num_bombs = num_bombs == 1 ? EASY : num_bombs == 2 ? NORMAL : HARD; + num_bombs = width * height / num_bombs; + 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):"); + scanf("%d", &width); + getchar(); + width = width == 1 ? SMALL : width == 2 ? MIDDLE : LARGE; + height = width; + num_bombs = width * height / num_bombs; + break; + case 3: + printf("Bitte Breite des Spielfeld eingeben:"); + scanf("%d", &width); + getchar(); + printf("Bitte Hoehe des Spielfeld eingeben:"); + scanf("%d", &height); + getchar(); + printf("Bitte Anzahl der Bomben eingeben:"); + scanf("%d", &num_bombs); + getchar(); + break; + case 4: + running = false; + break; + + default: + break; + } + } } \ No newline at end of file