This is a starter repo for the Capstone project in the Udacity C++ Nanodegree Program. The code for this repo was inspired by this excellent StackOverflow post and set of responses.
The Capstone Project gives you a chance to integrate what you've learned throughout this program. This project will become an important part of your portfolio to share with current and future colleagues and employers.
In this project, you can build your own C++ application or extend this Snake game, following the principles you have learned throughout this Nanodegree Program. This project will demonstrate that you can independently create applications using a wide range of C++ features.
- 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
.
This version features several new features compared to the original including a second snake that moves randomly, a score leaderboard, and the ability to control the initial speed the snakes move at. You must avoid the snake moving randomly, if it touches you or you touch it, the game is over. The score leaderboard is accessible as a scores.txt file and shows the top 10 scores achieved. To control the initial speed of the game you can change a speed.txt file to be any value you would like.
This program demonstrates an understanding of C++ functions and control structures (throughout).
This program reads and writes to an external file as part of its necessary operation (scores.cpp, snake.cpp lines 6-18).
This program accepts user input and processes the input (input from files - scores.cpp, snake.cpp lines 6-18)
This program uses data structures and immutable variables (throughout, e.g. scores.cpp).
One or more classes are added to the project with appropriate access specifiers for class members (random_snake.h, scores.h)
Class constructors utilize member initialization lists (snake.cpp lines 6-18, random_snake.cpp lines 7-16)
Classes abstract implementation details from their interfaces (snake.h, random_snake.h, scores.h)
Classes follow an appropriate inheritance hierarchy with virtual and override functions (snake.h, random_snake.h)
The project makes use of references in function declarations (snake.h line 29, game.h line 14, controller.h lines 8 and 11, renderer.h line 16)
The project uses score / Resource Aquisition is Initialization (RAII) where appropriate (scores.h)
The project uses smart pointers instead of raw pointers (scores.h line 17)
The project uses multithreading (game.cpp lines 74-78)
A promise and future is used in the project (game.cpp lines 74-78)
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.