111.2 CS1010301 物件導向程式設計實習 踩地雷遊戲.
MineSweeper game with GUI supported, writing in C++.
- Windows MSVC
- MacOS AppleClang
- Linux GCC/Clang
⚠️ Apple Silicon (arm64) is not currently supported.
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
The game support in console mode and GUI mode.
We can use launch arguments to run the game in different mode.
By default run the game it running in GUI mode.
./MineSweeper CommandInput
./MineSweeper CommandFile <InputCommandFile> <OutputResultFile>
./MineSweeper GUI
- Standby
- Playing
- GameOver
Command | Usage | Standby | Playing | GameOver |
---|---|---|---|---|
Load |
Load game board | ✅ | ||
StartGame |
Start game | ✅ | ||
Print |
Print the information | ✅ | ✅ | ✅ |
LeftClick |
Left click a block (Uncover block) | ✅ | ||
RightClick |
Right click a block (Put flag) | ✅ | ||
Replay |
Start a new game | ✅ | ||
Quit |
Quit game | ✅ |
Load <Load Mode...>
Load the generated board file
Load BoardFile <file_path>
Load BoardFile ./boards/board1.txt
Generate a board with random count mines
Load RandomCount <width> <height> <mines_count>
Load RandomCount 10 10 10
Generate a board with random rate mines
Load RandomRate <width> <height> <mines_rate>
Load RandomRate 10 10 0.3
Print <Print Mode...>
Current game board
- Covered block
#
- Uncovered block
number
- Flag
f
- Question Mark
?
- Mine
X
Print GameBoard
0 0 0 0 0 0 0 0 1 #
0 0 0 0 0 0 0 0 1 1
1 1 1 0 0 0 0 0 0 0
# f 1 0 1 1 2 1 1 0
1 1 1 0 1 # ? # 2 1
0 0 0 0 1 1 # # # #
0 0 0 0 0 1 # # # #
0 0 0 0 1 2 # # # #
1 2 1 1 1 # # # # #
# # # # # # # # # #
Print GameAnswer
0 0 0 0 0 0 0 0 1 X
0 0 0 0 0 0 0 0 1 1
1 1 1 0 0 0 0 0 0 0
1 X 1 0 1 1 2 1 1 0
1 1 1 0 1 X 2 X 2 1
0 0 0 0 1 1 2 1 2 X
0 0 0 0 0 1 1 1 1 1
0 0 0 0 1 2 X 1 0 0
1 2 1 1 1 X 3 2 0 0
X 2 X 1 1 2 X 1 0 0
Current game state (Standby/Playing/GameOver).
Current bomb(mines) count in the board.
Current flags count in the board.
Current uncovered block count in the board.
Current covered block count in the board.