↓ Skip to main content
  1. Projects/

CLI Snake

·184 words·1 min
Table of Contents

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
#

  1. Generation of random game sets or events
    • The apples are generated at random (uniformly distributed) around the map.
    • mt19937 pseudo-random generator is used.
  2. Data structures for storing game status
    • Class Snake, will store all the properties of the current snake.
    • Class SaveAndLoad, for save and load methods.
  3. Dynamic memory management
    • new operator is used to allocate memory on the free store for Snake and SaveAndLoad objects.
    • delete operator is called to restore the memory allocated when the game ends.
  4. 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
#

Ian Lo
Author
Ian Lo
Be Prepared

Related