Console Snake Game
Introduction
The Console Snake game with background music was implemented using C++ and the libraries libncurses and libcplayer. libncurses (new curses) is a programming library providing an application programming interface (API) that allows the programmer to write text-based user interfaces in a terminal-independent manner. libcplayer(console player) is a C++ library for playing background audios asynchronously in C++ programs.
Dependencies
- CMake 3.13.0+
- libncurses 6.1+
libsndfilelibasoundlibcplayer
Files
1 | . |
Installation
Build Docker Image
1 | $ docker build -f docker/snake.Dockerfile --no-cache --tag snake:0.0.1 . |
Run Docker Container
1 | $ docker run -it --rm --device /dev/snd -v $(pwd):/mnt -w /mnt snake:0.0.1 |
Install CMake
Check out the installation guide from Kitware.
Install Dependencies
1 | $ sudo apt-get install libncurses-dev libsndfile-dev libasound2-dev |
Install Game
Because the installation requires to use git submodule, please git clone instead of download the repository.
1 | $ git clone https://github.com/leimao/Console-Snake.git |
Usages
Game Rules
Control the snake to eat food as much as possible. You get one point for every food your snake eat. The level of difficulty would increase every 5 points you get.
Play Game Using Default BGM
1 | $ cd bin/ |
Play Game Using Custom BGM
The user is also allowed to use custom BGMs.
1 | $ cd bin/ |
Currently the game only supports wav, ogg, and flac audio formats.
Demo
References
GitHub
Console Snake Game