Browse Source

Minesweeper adding Win and Loss

remotes/origin/David
David Moeller 11 months ago
parent
commit
8e4593aaa4
  1. 8
      src/main/c/Minesweeper/minesweeper_start.c
  2. 3
      src/main/c/Snake/snake_start.c

8
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;}
}
}

3
src/main/c/Snake/snake_start.c

@ -5,12 +5,15 @@
#include <stdlib.h>
#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();

Loading…
Cancel
Save