Giter Club home page Giter Club logo

udacity-cppnd-capstone-snake-game's Introduction

CPPND: Capstone Snake Game

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.

In this project, I extend this Snake game to the following directions:

  1. add obstacles (shown as grey rectangles) to the map
  2. add another snake which follows the path (shown as green grids) calculated from A* algorithm.
  3. allow user to enter their names before playing game
  4. log user's score in a file named users_info.txt located in build folder.

The above is a short video to illustrate the extended game.

The most time-consuming part when I implemented the extensions is to determine the direction for each move according to the path from A* algorithm. The moving speed is not accurate 0.1 so this cause some trouble to predict the accurate position after each move. Through careful observations, I realize we can use static_cast<int>(head_x/y) instead of head_x/y because we only care about the head's integer position in rendering and determining whether it arrives at the food. So I use static_cast<int>(head_x/y) to infer the moving direction and determine whether we should pop out the previous goal (last grid in path) dynamically.

Project rubric

  • README
  • Compiling and Testing
  • Loops, Functions, I/O [link]
  • Object Oriented Programming [link]

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.

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

udacity-cppnd-capstone-snake-game's People

Contributors

maxispeicher avatar ruanyyyyyyy avatar sudkul avatar swwelch 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.