diff options
| author | dawidg81 <dawidgorski.m@gmail.com> | 2026-01-26 17:24:50 +0100 |
|---|---|---|
| committer | dawidg81 <dawidgorski.m@gmail.com> | 2026-01-26 17:24:50 +0100 |
| commit | 3806bb74674f305679efdaa2889d155531bc3643 (patch) | |
| tree | dcced6c118fb6ed61824bb0bcd24d1ae6aed258c /src/Game | |
| parent | b492bfb0d4cafe69edf69f196911f1b0e64c43df (diff) | |
dir rename
Diffstat (limited to 'src/Game')
| -rw-r--r-- | src/Game/Game.hpp | 24 | ||||
| -rw-r--r-- | src/Game/display.cpp | 14 | ||||
| -rw-r--r-- | src/Game/edit.cpp | 24 | ||||
| -rw-r--r-- | src/Game/init.cpp | 38 |
4 files changed, 100 insertions, 0 deletions
diff --git a/src/Game/Game.hpp b/src/Game/Game.hpp new file mode 100644 index 0000000..767ab94 --- /dev/null +++ b/src/Game/Game.hpp @@ -0,0 +1,24 @@ +#ifndef GAME_HPP +#define GAME_HPP + +class Game { +private: + static constexpr int MAX_W = 32; + static constexpr int MAX_H = 32; + + int boardWidth; + int boardHeight; + + bool bombMap[MAX_H][MAX_W]; + int tileMap[MAX_H][MAX_W]; + + int mines; + +public: + int editDiff(); + void initDiff(int diff); + void initBoard(); + void displayBoard(); +}; + +#endif diff --git a/src/Game/display.cpp b/src/Game/display.cpp new file mode 100644 index 0000000..4fb16cb --- /dev/null +++ b/src/Game/display.cpp @@ -0,0 +1,14 @@ +#include "Game.hpp" + +#include <cstdlib> +#include <cstdio> +#include <iostream> + + +void Game::displayBoard() { + for (int i = 0; i < boardHeight; i++) { + for (int j = 0; j < boardWidth; j++) + putchar(tileMap[i][j]); + putchar('\n'); + } +}
\ No newline at end of file diff --git a/src/Game/edit.cpp b/src/Game/edit.cpp new file mode 100644 index 0000000..8d9c37f --- /dev/null +++ b/src/Game/edit.cpp @@ -0,0 +1,24 @@ +#include "Game.hpp" +#include "../Utils/Utils.hpp" + +#include <cstdlib> +#include <cstdio> +#include <iostream> +#include <string> + +int Game::editDiff(){ + Utils util; + + std::cout << "Now editing custom difficulty" << std::endl; + + std::cout << "Board width: "; + if(util.catchReturn(util.catchInputInt(Game::boardWidth)) != 0) return 1; + + std::cout << "Board height: "; + if(util.catchReturn(util.catchInputInt(Game::boardHeight)) != 0) return 1; + + std::cout << "Mines: "; + if(util.catchReturn(util.catchInputInt(Game::mines)) != 0) return 1; + + return 0; +}
\ No newline at end of file diff --git a/src/Game/init.cpp b/src/Game/init.cpp new file mode 100644 index 0000000..a572fbc --- /dev/null +++ b/src/Game/init.cpp @@ -0,0 +1,38 @@ +#include "Game.hpp" + +#include <cstdlib> +#include <cstdio> +#include <iostream> + +void Game::initDiff(int diff) { + switch (diff) { + case 0: + boardWidth = 9; + boardHeight = 9; + mines = 9; + break; + case 1: + boardWidth = 16; + boardHeight = 16; + mines = 12; + break; + case 2: + boardWidth = 30; + boardHeight = 16; + mines = 16; + break; + case 3: + std::cout << "Editing game parameters\n"; + break; + } +} + +void Game::initBoard() { + for (int i = 0; i < boardHeight; i++) + for (int j = 0; j < boardWidth; j++) + bombMap[i][j] = rand() % 2; + + for (int i = 0; i < boardHeight; i++) + for (int j = 0; j < boardWidth; j++) + tileMap[i][j] = 0; +}
\ No newline at end of file |
