diff options
| -rw-r--r-- | TODO.txt | 3 | ||||
| -rw-r--r-- | minesweeper.exe | bin | 124188 -> 155957 bytes | |||
| -rw-r--r-- | src/Game.cpp | 28 | ||||
| -rw-r--r-- | src/Game.hpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 1 |
5 files changed, 12 insertions, 22 deletions
@@ -1,3 +1,4 @@ Things to do: -X - make safe tiles reveal recursively
\ No newline at end of file +V - make safe tiles reveal recursively +X - colors
\ No newline at end of file diff --git a/minesweeper.exe b/minesweeper.exe Binary files differindex 2dff3e0..f0e510d 100644 --- a/minesweeper.exe +++ b/minesweeper.exe diff --git a/src/Game.cpp b/src/Game.cpp index 18e09cd..4e44888 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -3,6 +3,7 @@ #include <cstdlib> #include <cstdio> #include <iostream> +#include <ostream> #include <string> void Game::initDiff(int diff) @@ -171,7 +172,7 @@ int Game::bombCheck(int x, int y) return count; } -void Game::revealTile(int x, int y){ +void Game::revealTile(int y, int x){ revealedMap[y][x] = true; if(bombCheck(x, y) == 0) @@ -185,6 +186,7 @@ void Game::revealTile(int x, int y){ if(nx >= 0 && nx < boardWidth && ny >= 0 && ny < boardHeight && !revealedMap[ny][nx]){ revealedMap[ny][nx] = true; + revealTile(ny, nx); } } } @@ -198,6 +200,8 @@ void Game::input() std::cout << "game> "; std::cin >> cmd; + // std::cout << cmd; + if(std::cin.fail()) { std::cout << "Input failed." << std::endl; @@ -206,14 +210,14 @@ void Game::input() return; } - if(cmd == "q"){ + if(cmd == "q") + { inGame = false; return; } int x, y; std::cin >> x >> y; - std::cout << x << y; if(x < 0 || x >= boardWidth || y < 0 || y >= boardHeight) return; @@ -234,23 +238,7 @@ void Game::input() if(!revealedMap[y][x]) { - revealedMap[y][x] = true; - - if(bombCheck(x, y) == 0) - { - for(int dy = -1; dy <= 1; dy++) - { - for(int dx = -1; dx <= 1; dx++) - { - int nx = x + dx; - int ny = y + dy; - - if(nx >= 0 && nx < boardWidth && ny >= 0 && ny < boardHeight && !revealedMap[ny][nx]){ - revealedMap[ny][nx] = true; - } - } - } - } + revealTile(y, x); } } diff --git a/src/Game.hpp b/src/Game.hpp index 15eadd3..749f75d 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -30,7 +30,7 @@ public: int bombCheck(int x, int y); - void revealTile(int x, int y); + void revealTile(int y, int x); void input(); }; diff --git a/src/main.cpp b/src/main.cpp index 21ceb01..97117a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,7 @@ int main(){ game.displayBoard(); game.input(); game.updateBoard(); + // cout << game.inGame; } return 0; |
