summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Game.cpp23
-rw-r--r--src/Game.hpp4
-rw-r--r--src/main.cpp2
3 files changed, 24 insertions, 5 deletions
diff --git a/src/Game.cpp b/src/Game.cpp
index e81ccd3..c9c53dd 100644
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -62,11 +62,17 @@ void Game::updateBoard()
{
for(int x=0; x < boardWidth; x++)
{
- if(flagMap[y][x] == true)
+ if (flagMap[y][x] == true)
{
tileMap[y][x] = 10;
continue;
}
+ else if (!flagMap[y][x] && !revealedMap[y][x])
+ {
+ tileMap[y][x] = 0;
+ continue;
+ }
+
else if(!revealedMap[y][x]) continue;
int bombs = bombCheck(x, y);
@@ -134,10 +140,18 @@ void Game::displayBoard()
system("clear");
#endif
- std::cout << msg;
+ std::cout << msg << "\n ";
+
+ for (int i = 0; i < boardHeight; i++) {
+ std::cout << i;
+ }
+
+ std::cout << "\n\n";
for(int y=0; y < boardHeight; y++)
{
+ std::cout << y << " ";
+
for(int x = 0; x < boardWidth; x++)
{
if(tileMap[y][x] == 0) putchar('#');
@@ -148,6 +162,7 @@ void Game::displayBoard()
putchar('\n');
}
+ putchar('\n');
}
int Game::bombCheck(int x, int y)
@@ -267,6 +282,10 @@ void Game::input()
if(revealedMap[y][x])
{
msg = "You can't place flag on revealed tile.\n";
+ }
+
+ if(flagMap[y][x]){
+ flagMap[y][x] = false;
} else {
flagMap[y][x] = true;
}
diff --git a/src/Game.hpp b/src/Game.hpp
index a723f5d..9b720a9 100644
--- a/src/Game.hpp
+++ b/src/Game.hpp
@@ -17,12 +17,12 @@ private:
int mines;
+ std::string msg;
+
public:
bool inGame;
bool hasWon();
- std::string msg;
-
int editDiff();
void initDiff(int diff);
void initBoard();
diff --git a/src/main.cpp b/src/main.cpp
index 16a8b13..8bbb1d9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,7 +43,7 @@ int main(){
game.input();
game.updateBoard();
game.hasWon();
- cout << game.msg;
+ // cout << game.msg;
// cout << game.inGame;
}