Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom field params #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ dir:
build: dir
g++ -Wall -pedantic -ansi -std=c++17 ./src/*.cpp -o ./build/minesweeper.bin


columns=16
rows=9
mines=15
run:
./build/minesweeper.bin
./build/minesweeper.bin $(columns) $(rows) $(mines)

clean:
rm -rf ./build/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Having `g++` with C++ 17 support, just run this inside the cloned repository:
make
```

## Customize game

You can choose the number of rows and columns on the board and the number of mines.

For this, use the columns, rows and mines optional variables when run make:

```sh
make columns=10 rows=4 mines=8
```

That's it. Compiled using my Pop!_OS. I have no idea of how to run it in other environments.

## Disclaimer
Expand Down
15 changes: 13 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ bool is_number(const std::string& s)
[](unsigned char c) { return !std::isdigit(c); }) == s.end();
}

int main() {
int main(int argc, char *argv[]) {

if (argc != 4) {
std::cout << "Please, give correct number of arguments.";
return 0;
}

int COLUMNS, ROWS, MINES;
COLUMNS = std::stoi(argv[1]);
ROWS = std::stoi(argv[2]);
MINES = std::stoi(argv[3]);

srand(time(NULL));
std::string input_x, input_y;
int x, y;
char operation;
std::string message = "Let's wait for your first move. Hope you're not nervous.";

Game::MineField field (16, 9, 15);
Game::MineField field (COLUMNS, ROWS, MINES);

while (true) {
std::system("clear || cls");
Expand Down