From 96ae64a3e5e6b06198d064ee23c12a0c36581e13 Mon Sep 17 00:00:00 2001 From: dawidg81 Date: Sat, 17 Jan 2026 16:05:47 +0100 Subject: Added main.cpp --- src/main.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..920f28f --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +bool inGame = false; + +void game(int diff){ + int boardWidth; + int boardHeight; + int board[boardWidth][boardHeight]; + int mines; + + switch(diff){ + case 0: + boardWidth = 9; + boardHeight = 9; + mines = 9; + break; + + case 1: + boardWidth = 16; + boardHeight = 16; + mines = 12; + break; + + case 2: + boardWidth = 30; + boardHeight = 16; + mines = 16; + break; + + case 3: + cout << "Editing game parameters\n"; + + cout << "Board Width: "; + cin >> boardWidth; + + if(boardWidth > 32){ + cout << "Board width can't be more than 32 cells.\n"; + } else if(boardWidth < 8){ + cout << "Board width can't be less than 8 cells.\n"; + } + + cout << "Board Height: "; + cin >> boardHeight; + + if(boardHeight > 32){ + cout << "Board height can't be more than 32 cells.\n"; + }else if(boardHeight < 8){ + cout << "Board height can't be less than 8 cells.\n"; + } + + cout << "Mines: "; + cin >> mines; + + if(mines > 16){ + cout << "There can't be more than 16 mines.\n"; + } + + break; + } +} + +int main(){ + int choice; + + while(inGame == false){ + cout << "Welcome to minesweeper 0.1.0\n"; + cout << "\n"; + cout << "Select difficulty:\n" + "1. Easy\n" + "2. Medium\n" + "3. Hard\n" + "4. Custom\n"; + cout << "Difficulty: "; + cin >> choice; + + if(choice == 1){ + game(0); + } else if(choice == 2){ + game(1); + } else if(choice == 3){ + game(2); + } else if(choice == 4){ + game(3); + } + } + + return 0; +} -- cgit v1.2.3