A classic Snake game developed in C++ to run in terminal. The game is built using the ncurses library to handle the terminal display and input. The game is designed to be lightweight and with a simple interface and controls.
Game Elements #
- 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
new
operator is used to allocate memory on the free store forSnake
andSaveAndLoad
objects.delete
operator 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.txt
file, and continue to play. - After the game ends, the score will be recorded in the
leaderboard.txt
file. - Files are saved under
log
directory.
GitHub Repository #
iltlo/Snake
Course Group Project of HKU ENGG1340
C++
2
1