summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordawidg81 <dawidgorski.m@gmail.com>2026-01-25 15:03:01 +0100
committerdawidg81 <dawidgorski.m@gmail.com>2026-01-25 15:03:01 +0100
commit0d2cffff89dd0bf752cff5a5d8dbebc22a2dc01e (patch)
tree4dafb5c081093693fdc85e769c94714349a5f65b
parentf227a252d8f109e01e7b33c44ba587b0b9e05d11 (diff)
added displayBoard and initialized tile map in game.cpp
-rw-r--r--src/game/game.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index eefbe02..80f25bf 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -1,3 +1,4 @@
+#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sys/stat.h>
@@ -14,8 +15,8 @@ private:
int boardWidth;
int boardHeight;
- bool bombmap[MAX_H][MAX_W];
- int displaymap[MAX_H][MAX_W];
+ bool bombMap[MAX_H][MAX_W];
+ int tileMap[MAX_H][MAX_W];
int mines;
@@ -75,7 +76,25 @@ public:
void initBoard(){
for(int i = 0; i < boardHeight; i++){
for(int j = 0; j < boardWidth; j++){
- bombmap[i][j] = rand() % 2;
+ // false = no bomb; true = bomb;
+ bombMap[i][j] = rand() % 2;
+ }
+ }
+
+ for (int i = 0; i < boardHeight; i++) {
+ for (int j = 0; j < boardWidth; j++) {
+ // 0 = unrevealed tile
+ // 1 = revealed tile
+ // from 2 to 10 - revealed tiles with numbers
+ tileMap[i][j] = 0;
+ }
+ }
+ }
+
+ void displayBoard(){
+ for (int i = 0; i < boardHeight; i++) {
+ for (int j = 0; j < boardWidth; j++) {
+ putchar(tileMap[i][j]);
}
}
}