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, I added these features to accomplish the project rubric requirements:
- Added an enemy in the game as an extra feature.
- Loops, Functions, I/O
- Using control structures and organizing the code in functions.
- Accepting input from the user.
- Object Oriented Programming
- Using object oriented programming techniques.
- Using appropriate access specifiers for members.
- Using member initialization lists.
- Member data that is subject to an invariant is hidden from the user.
- Classes follow an appropriate inheritance hierarchy.
- Overriding a virtual base class function.
- Memory Management
- Using RAII where appropriate.
- Smart pointers used instead of raw pointers.
- If enemy snake bites the player snake from its tail, player snake will get short.
- If player snake touches the enemy snake, the player snake will die.
- When player eats a food, gets a point. But the only way to win the game is staying alive before the enemy takes a bite itself!
- 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 work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.