The code for this repo was inspired by this excellent StackOverflow post and set of responses.
- 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++ >= 5.4
- 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
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./SnakeGame
.
- The game has three different feeding points a normal, shrink ,killer.
- Normal feed point grow the snake by one cell and increase it's speed.
- Shrink feed point shring the snake back to one cell size and restore it's defult speed.
- For each shrink feeding point taken by the player a premenent killer point will be placed on the play board.
- If the player eaten any of the killer red points instant death is the result.
- If the player hit his body with his head instant death is the result.
- When the game ends it store the final score to scores file and retrieve the highest score from that file and print it in terminal
There are 5 classes in My Submitted implementation.
class name | Purpose |
---|---|
Controller | Interact with users, let users use keyboard to control the snake in the game. |
Game | Game class stores the state in the game, the function object run has the game run in loops til end. |
Renderer | render the game to the screen. |
Snake | contains attributes to keep track of the Snake speed, size, and location. |
Logger | Read, Write and print the history record for players. |