- Lai, Pok Hang
- Lo, Ian Leong Ting
- Keys:
- Arrow / WASD: Menu bar navigation, snake movement control
- Enter: Select menu option
- Spacebar: Pause
- Snake should move only inside the yellow border and search for food (red apple).
- Once the food was eaten, the snake body grows one unit in length.
- Game ends if the snake crashes with itself or to the wall.
- Try to control the snake to eat as many apples as possible!
- Generation of random game sets or events
- The apples are generated at random (uniformly distributed) around the map.
- mt19937 pseudo-random generator is used.
- Data structures for storing game status
- Class
Snake, will store all the properties of the current snake. - Class
SaveAndLoad, for save and load methods.
- Class
- Dynamic memory management
newoperator is used to allocate memory on the free store forSnakeandSaveAndLoadobjects.deleteoperator is called to restore the memory allocated when the game ends.
- File input/output
- The pause menu provides the option to save current game status.
- At start menu, the saved game can be loaded from the
log.txtfile, and continue to play. - After the game ends, the score will be recorded in the
leaderboard.txtfile. - Files are saved under
logdirectory.
- Program codes in multiple files
./includecontains header files./srccontains source files./logcontains files for saving and loading game status
- Run the following commands in the project root directory
- Install ncurses library and compile the project
make all
- Run the game
./main
make ncurseswill automatically run uponmake all, it will clone thencurseslibrary under the project directory (./ncurses), and install it under your home directory (~/ncurses_files). Make sure that no non-empty colliding directories exist.- The clone, install and compile process takes around 1-2 minutes when running
make allthe first time. make cleancan remove object files and executable.make clear-scorecan clear the game score history.- Fully built and tested on HKU
academy11server.
ncurses
.
├── Makefile
├── README.md
├── demo
│ ├── demo_1.png
│ ├── demo_2.png
│ ├── demo_3.png
│ └── demo_4.png
├── get_ncurses.sh
├── include
│ ├── new_game.hpp
│ ├── pause_menu.hpp
│ ├── save_and_load.hpp
│ ├── snake.hpp
│ ├── start_menu.hpp
│ └── visuals.hpp
├── log
│ ├── clear-score.sh
│ ├── leaderboard.txt
│ └── state.txt
├── main.cpp
├── ncurses
└── src
├── new_game.cpp
├── pause_menu.cpp
├── save_and_load.cpp
├── snake.cpp
├── start_menu.cpp
└── visuals.cpp



