Skip to content

ofarukcaki/CppND-Capstone-Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 extended the Snake Game by following the principles I learned throughout the c++ Nanodegree Program. See Rubric Points

New Features

  • Pause

    • Game can be paused/resumed by pressing ESC button.
  • There is a wall option available.

    • Pressing the w key will enable/disable the wall around the game table.
    • Snake can't appear on the other side of the screen if the wall is active and this will result the death of the snake.
  • Modal box added

    • When you die, a small dialog box appears and shows score and size informations. Console output is still available
  • Toxic Foods

    • There is a 20% chance for a toxic food.
    • Toxic foods are unidentified until eaten and if snake eats a toxic food it will be poisoned for 5 seconds.
    • Poisoned snake will go in opposite direction. For ex. pressing UP key will result to go DOWN. This effect will last for 5 seconds.

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

The project code is clearly organized into functions and classes. All reusable codes implemented as function in order to prevent copy-paste codes.

Project accept user inputs during the game, these inputs are used by controlling the snake and other game features such as pausing and triggering the wall.

Object Oriented Programming

The project code is organized into classes with class attributes to hold the data, and class methods to perform tasks.

All class data members are explicitly specified as public, protected, or private.

THe project make use of friend classes.

All class methods are commented about their functionality.

Memory Management

The project makes use of references in function declarations. Both references and pointers used all around the project.

Concurrency

The project creates a thread each time snake is poisoned. This thread waits for 5 seconds and return back the snake's poisonous state to normal by modifying the game's private pointer variable.

About

Snake Game in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published