Skip to content

jmassey-17/CppND-Capstone-Snake-Game-1

 
 

Repository files navigation

CPPND: Capstone Snake Game

This is 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.

In this project, I used what I learnt in the C++ Nanodegree to extend the Snake game.

New Features

  • Obstacles:
    • Obstacles are now part of the game and are added to the board every time the snake eats food.
  • Game modes: The game comes with 4 possible modee, which are selected in the console before the game initializes. The modes are:
    • 1: Classic Snake
    • 2: Snake With Static Obstacles
    • 3: Snake with randomly moving obstacles
    • 4: Snake with Obstacles that chase the head of the snake round the board.

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./SnakeGame.

Rubric Points

Loops, Functions, I/O

  • Project accepts user input to determine game mode
  • Project is organised into functions.
  • Project uses arrays, vectors and constant variables.

Object Oriented Programming

  • All functions within classes have their purpose and function documented.
  • Project is organized into classes, with
  • Constructor and destructor of the game class have been expanded.

Memory Management

  • Destructor of the game class is used to tidy up threads.
  • References are called to manage implementation of obstacles vector and manage the threads.
  • Snake is implemented as a unique pointer.

Concurrency

  • Project splits the snake and the obstacle movement into two threads and runs them concurrently.
  • Mutex and a lock is used for this, as is a conditional variable.

About

A 2D Snake game using C++ and SDL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 38.7%
  • Makefile 29.5%
  • C 16.5%
  • CMake 15.3%