diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | minesweeper.exe | bin | 158662 -> 0 bytes | |||
| -rw-r--r-- | src/Game.cpp | 23 | ||||
| -rw-r--r-- | src/Game.hpp | 4 | ||||
| -rw-r--r-- | src/main.cpp | 2 |
5 files changed, 25 insertions, 5 deletions
@@ -1,2 +1,3 @@ *.o +*.exe minesweeper diff --git a/minesweeper.exe b/minesweeper.exe Binary files differdeleted file mode 100644 index c4cde59..0000000 --- a/minesweeper.exe +++ /dev/null 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; } |
