summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordawidg81 <dawidgorski.m@gmail.com>2026-02-08 17:26:56 +0100
committerdawidg81 <dawidgorski.m@gmail.com>2026-02-08 17:26:56 +0100
commit80553898f80858e6e66613c889ed9f19327a1cf6 (patch)
tree0ca333367154ed09a1afad8eac1a8d7600cd28d5 /src
parentabdfe47e0fcc7755cd143c6515881314d07a686a (diff)
Attempts to fix flags displaying
Diffstat (limited to 'src')
-rw-r--r--src/Game.cpp21
-rw-r--r--src/Game.hpp4
2 files changed, 12 insertions, 13 deletions
diff --git a/src/Game.cpp b/src/Game.cpp
index f3d92f6..d98c5e9 100644
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -29,9 +29,9 @@ void Game::initBoard(){
for(int y=0; y < boardHeight; y++){
for(int x=0; x < boardWidth; x++){
bombMap[y][x] = false;
- revealed[y][x] = false;
+ revealedMap[y][x] = false;
tileMap[y][x] = 0;
- // flag[y][x] = false;
+ flagMap[y][x] = false;
}
}
@@ -50,9 +50,8 @@ void Game::initBoard(){
void Game::updateBoard(){
for(int y=0; y < boardHeight; y++){
for(int x=0; x < boardWidth; x++){
- if(!revealed[y][x]) continue;
- if(flag[y][x]) tileMap[y][x] = 10;
- else tileMap[y][x] = 10;
+ if(!revealedMap[y][x]) continue;
+ else if(flagMap[y][x] == true) continue;
int bombs = bombCheck(x, y);
tileMap[y][x] = bombs == 0 ? 1 : bombs + 1;
@@ -170,16 +169,16 @@ void Game::input(){
return;
}
- if(!revealed[y][x]){
- revealed[y][x] = true;
+ 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 && !revealed[ny][nx]){
- revealed[ny][nx] = true;
+ if(nx >= 0 && nx < boardWidth && ny >= 0 && ny < boardHeight && !revealedMap[ny][nx]){
+ revealedMap[ny][nx] = true;
}
}
}
@@ -188,10 +187,10 @@ void Game::input(){
}
if(cmd == "f"){
- if(revealed[y][x]){
+ if(revealedMap[y][x]){
std::cout << "You can't place flag here.\n";
} else {
- flag[y][x] = true;
+ flagMap[y][x] = true;
}
}
}
diff --git a/src/Game.hpp b/src/Game.hpp
index ca3cb33..599259f 100644
--- a/src/Game.hpp
+++ b/src/Game.hpp
@@ -10,8 +10,8 @@ private:
bool bombMap[MAX_H][MAX_W];
int tileMap[MAX_H][MAX_W];
- bool revealed[MAX_H][MAX_W];
- bool flag[MAX_H][MAX_W];
+ bool revealedMap[MAX_H][MAX_W];
+ bool flagMap[MAX_H][MAX_W];
int mines;