-
Notifications
You must be signed in to change notification settings - Fork 0
/
playable.cpp
54 lines (52 loc) · 1.58 KB
/
playable.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <string>
#include "Board.h"
void clearScreen() {
// ANSI escape code to clear the screen and move the cursor to the top-left corner
std::cout << "\033[2J\033[1;1H";
}
int main() {
int width, height, num_mines;
std::string mode;
std::cout << "Enter game mode: EASY, MEDUIM OR HARD: ";
std::cin >> mode;
while (mode != "EASY" && mode != "MEDUIM" && mode != "HARD"){
std::cout << "ERROR!!!! Enter correct mode in ALL CAPSs: \n";
std::cout << "Enter game mode: EASY, MEDUIM OR HARD: ";
std::cin >> mode;
}
if (mode == "EASY"){
width = 10;
height = 8;
num_mines= 10;
}else if (mode == "MEDUIM"){
width = 18;
height = 14;
num_mines= 40;
}else{
width = 24;
height = 20;
num_mines= 99;
}
Board mines(height, width, num_mines);
mines.revealed_board();
int row, coln;
std::cout << "Enter a row and colunm to dig: ";
std::cin >> row >> coln;
mines.place_mines(row, coln);
mines.update_count();
bool haveWon, haveLost;
mines.recurse_tile(row, coln);
haveWon = mines.have_won(row, coln);
haveLost = mines.have_lost(row, coln);
while ((!haveWon) && (!haveLost)){
clearScreen(); // Clear the screen before re-drawing the board
mines.revealed_board();
std::cout << "Enter a row and colunm to dig: ";
std::cin >> row >> coln;
mines.recurse_tile(row, coln);
haveWon = mines.have_won(row, coln);
haveLost = mines.have_lost(row, coln);
}
return 0;
}