The code for this repo was inspired by this excellent StackOverflow post and set of responses.
- Collecting the apples increases the score and speeds up the snake.
- Collecting lightning speeds up the snake.
- Collecting the yellow slow/caution diamond will slow down the snake.
- Collecting poision bottle or colliding into the body will lead to the game ending.
Change the numbers in the game-config.txt file to change the game config.
- First line contains config for the number of poison bottles on the grid.
- Second line contains config for the number of yellow slowdown/caution diamonds on the grid.
- Third line contains config for the number of lightning speedups on the grid.
- Finally, the last line contains config for the number of apples on the grid.
- cmake >= 3.7
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- SDL2 >= 2.0
- All installation instructions can be found here
Note that for Linux, an
apt
orapt-get
installation is preferred to building from source. - gcc/g++ >= 9.3
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
- Execute the build script with
./build.sh
to build the project. - To run execute the
./run.sh
script. The run script can be executed without the build script as well.
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./SnakeGame
.