This repository is the extended version of the following repository: https://github.com/avcode-exe/ENGG1340-Group-19-Project
HKU ENGG1340/COMP2113 (2023 - 2024) Group 19 Project
- Liu Hong Yuan Tom (3036262135)
- Wong Yiu Wing Wilson (3036262032)
- Ho Ho Cheung Sky (3036136934)
- Chan Ho Yin David (3036035075)
- Chan Pak Yin Perry (3036140284)
Our project consists of a maze game and a minesweeper game.
To begin with, the player has to complete the maze while avoiding monsters nearby. However, if the player gets hit by the monster, the player will be sent to a game of minesweeper. If the player loses during the minesweeper game, a health point will be deducted and the player returns to the maze game.
The goal is to reach the exit of the maze before the player loses all health points.
-
If you don't have
makeorg++installed:sudo apt install build-essential gdbsudo apt install make
-
Install dependencies:
sudo apt install libncurses5-dev libncursesw5-dev
-
Clone the repository:
git clone https://github.com/avcode-exe/ENGG1340-Group-19-Project-V2.git
-
Compile and run the game:
cd ENGG1340-Group-19-Project-V2make runormake+./mazeGame
-
A maze generated using recursive randomized Prim's algorithm
- A frontier is randomly selected from the list of potential frontiers using
<random>. The algorithm then removes the wall between the original coordinates and the selected frontier and thus carve a path. - STL vectors are used to initialize and store frontiers and their possible directions. It is also used for the
potentialFrontiersarray, a list of frontiers the algorithm can choose from randomly. - Dynamic pointers are used to instantiate objects of struct Cell for the Depth-First Search (DFS) algorithm, which finds the path from a starting position to the goal position in the maze.
- The maze generated is also saved to a text file using
<fstream>. The content of the maze in the text file is then loaded tomazeGame.cppand printed on the screen. - Different source code and header files are compiled separately in a Makefile.
- A frontier is randomly selected from the list of potential frontiers using
-
There are monsters moving in various locations of the maze and checkpoints generated in random locations
- MT19937 is used for the random generation of a random device, which is then used to shuffle the list of potential monster positions.
- STL vectors and pairs are used to store a list of potential monster positions, with the first value in the pair container being the x-coordinate and the second value being the y-coordinate.
- Monsters are represented with the character 'M' and are saved to the text file along with the maze.
- Different source code and header files are compiled separately in a Makefile.
-
A game of minesweeper commences when the player is hit by the monster
rand()from<cstdlib>is used to generate random coordinates for mines.- STL vectors are used to store a list of coordinates that have been visited by the player.
- The minesweeper game board is saved in a text file using
<fstream>, which is then loaded tominesweeper.cppand printed on the screen. - Different source code and header files are compiled separately in a Makefile.
- ncurses
-
Run the Game: After compiling the game using
make run, you will be prompted to choose whether to generate a new maze or use the previously saved maze:- Enter
yto generate a new maze. - Enter
nto use the previously saved maze.
- Enter
-
Initial Setup: You will start at the initial position of the maze with a certain number of health points (HP).
-
Movement: Use the following keys to navigate through the maze:
W: Move upA: Move leftS: Move downD: Move right
-
Objective: The goal is to reach the exit of the maze without losing all your health points.
-
Monsters: Monsters are represented by the character
Mand move dynamically within the maze. Avoid them to prevent losing health points.
If you get hit by a monster, you will be sent to a game of minesweeper:
-
Movement: Use the following keys to navigate through the minesweeper board:
W: Move upA: Move leftS: Move downD: Move right
-
Revealing Tiles: Press the
spacebarto reveal a tile:- If a mine (denoted by
X) is revealed, you lose the minesweeper game and return to the maze with one health point deducted. - If a number is revealed, it indicates how many mines are nearby within a 3 by 3 range.
- If an empty cell is revealed, it indicates no mines are nearby.
- If a mine (denoted by
-
Flag Mode: Press
Fto toggle flag mode. In flag mode, press thespacebarto place a flag on a tile, marking it as a potential mine.
- Winning: Reach the exit of the maze to win the game.
- Losing: If you lose all your health points, the game is over.
- Save Game: The game state, including the player's position, health points, and maze configuration will be saved to a test file when exiting the game via
xorX. - Resume Game: When starting the game, choose
nto resume from the last saved state.
- Health Points: Keep an eye on your health points displayed on the right side of the screen.
- Avoid Monsters: Plan your moves to avoid monsters and minimize health loss.
Have fun and good luck navigating the maze and playing minesweeper!
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
- Thanks to the HKU ENGG1340/COMP2113 course instructors and TAs for their guidance.
- Special thanks to all group members for their contributions and hard work.