Code Monkey home page Code Monkey logo

cppnd-capstone-snake-game's Introduction

CPPND: Capstone Snake Game

(I chose "CPPND : Capstone Snake Game" as a base project.)

In this game, you control a snake and guide it to a food. Yellow food is good for the snake, and the snake gets longer if the snake eats it. Red food is toxic, so the snake dies if the snake eats it.

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.

How to play

  • Control a snake and get a yellow food.

  • If the snake eats a yellow food, the snake gets longer, score increases, and the number of toxic food increases.

  • If the snake eats a red food, the snake dies and Game is over, because it is a toxic food.

  • How to control the snake : Use arrow keys.

  • Push "p" key to Pause the game, and push "r" key to Resume(Re-start) the game.

Rubric points addressed

I added or modified the features described below.

  1. Added Food class Rubric point in this item :

    1. The project uses Object Oriented Programming techniques. and Classes encapsulate behavior. Defined Food class to have some attributes. (e.g. Food.attr, Food.position)
    2. Classes use appropriate access specifiers for class members. Added some public functions to access class members in Food. void SetPosition(int x, int y); bool CheckIfFoodIsThere(int x, int y); SDL_Point GetPosition(); bool CheckFoodIsToxic();
    3. Class constructors utilize member initialization list Utilized member initialization lists for the private member "attr".
    4. The project makes use of references in function declarations. To access "Food vector elements" from "Renderer::Render()" function, passed "&food" as a reference.
  2. Added GameState class -> by this, player can pause/resume the game Rubric point in this item :

    1. The project accepts user input and processes the input. ("p" for pause, and "r" for resume the game)
    2. The project makes use of references in function declarations. To access "current_state" in "GameState" class from "Controller::HandleInput()" function, passed "GameState &state" as a reference.
    3. Class constructors utilize member initialization lists. Utilized member initialization lists for the private member "current_state" in GameState class.
  3. Increased number of food Rubric point in this item :

    1. The project demonstrates an understanding of C++ functions and control structures. Defined "std::vector food", and used "for ( auto f : food )" control structure in "Game::PlaceFood()" and "Game::Update()" and "Renderer::Render()".
  4. Added different type of food (Toxic food)

CC Attribution-ShareAlike 4.0 International

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

cppnd-capstone-snake-game's People

Contributors

chrismusashi85 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.