summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordawidg81 <dawidgorski.m@gmail.com>2026-01-24 09:41:25 +0100
committerdawidg81 <dawidgorski.m@gmail.com>2026-01-24 09:41:25 +0100
commit841a679e999bde905de5b7e994707d3c112f5375 (patch)
tree7f1ecaa67f20a6cbfaccc5eb68424ab64865f1d7 /src
parent96ae64a3e5e6b06198d064ee23c12a0c36581e13 (diff)
game functions moved into game.cpp and game.hpp
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp62
-rw-r--r--src/game.hpp7
-rw-r--r--src/main.cpp60
3 files changed, 70 insertions, 59 deletions
diff --git a/src/game.cpp b/src/game.cpp
new file mode 100644
index 0000000..0b15d96
--- /dev/null
+++ b/src/game.cpp
@@ -0,0 +1,62 @@
+#include <iostream>
+#include "game.hpp"
+using namespace std;
+
+bool inGame = false;
+
+void game(int diff){
+ int boardWidth;
+ int boardHeight;
+ int board[boardWidth][boardHeight];
+ int mines;
+
+ 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:
+ cout << "Editing game parameters\n";
+
+ cout << "Board Width: ";
+ cin >> boardWidth;
+
+ if(boardWidth > 32){
+ cout << "Board width can't be more than 32 cells.\n";
+ } else if(boardWidth < 8){
+ cout << "Board width can't be less than 8 cells.\n";
+ }
+
+ cout << "Board Height: ";
+ cin >> boardHeight;
+
+ if(boardHeight > 32){
+ cout << "Board height can't be more than 32 cells.\n";
+ }else if(boardHeight < 8){
+ cout << "Board height can't be less than 8 cells.\n";
+ }
+
+ cout << "Mines: ";
+ cin >> mines;
+
+ if(mines > 16){
+ cout << "There can't be more than 16 mines.\n";
+ }
+
+ break;
+ }
+} \ No newline at end of file
diff --git a/src/game.hpp b/src/game.hpp
new file mode 100644
index 0000000..b5a16d5
--- /dev/null
+++ b/src/game.hpp
@@ -0,0 +1,7 @@
+#ifndef GAME_HPP
+#define GAME_HPP
+
+bool inGame;
+void game(int diff);
+
+#endif \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 920f28f..f25a00a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,65 +1,7 @@
#include <iostream>
+#include "game.hpp"
using namespace std;
-bool inGame = false;
-
-void game(int diff){
- int boardWidth;
- int boardHeight;
- int board[boardWidth][boardHeight];
- int mines;
-
- 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:
- cout << "Editing game parameters\n";
-
- cout << "Board Width: ";
- cin >> boardWidth;
-
- if(boardWidth > 32){
- cout << "Board width can't be more than 32 cells.\n";
- } else if(boardWidth < 8){
- cout << "Board width can't be less than 8 cells.\n";
- }
-
- cout << "Board Height: ";
- cin >> boardHeight;
-
- if(boardHeight > 32){
- cout << "Board height can't be more than 32 cells.\n";
- }else if(boardHeight < 8){
- cout << "Board height can't be less than 8 cells.\n";
- }
-
- cout << "Mines: ";
- cin >> mines;
-
- if(mines > 16){
- cout << "There can't be more than 16 mines.\n";
- }
-
- break;
- }
-}
-
int main(){
int choice;