ptpam / CppND-Capstone-Snake-Game

A 2D Snake game using C++ and SDL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPPND: Capstone Snake Game Example

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, you can build your own C++ application or extend this Snake game, following the principles you have learned throughout this Nanodegree Program. This project will demonstrate that you can independently create applications using a wide range of C++ features.

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. To clean the bulid directory make clean
  3. Compile: make build
  4. Run it: ./build/SnakeGame.

Changes made

πŸ“€ Loops, Functions, I/O

Introduced clear and logical loops and functions, akin to a well-organized recipe for better code comprehension. Enabled efficient data reading from files, emphasizing a structured narrative. Additionally, implemented user-friendly input prompts for smoother interactions.

🎨 Object-Oriented Programming

Introduced new classes with appropriate access specifiers and methods, adhering to a structured organization for better code management. Established a rational inheritance hierarchy among classes, with virtual and override functions enhancing the code's extensibility. Utilized overloaded functions strategically to offer flexibility in code application, resembling a versatile toolkit.

🌐 Memory Management

Integrated destructors appropriately, aligning with the Resource Acquisition Is Initialization (RAII) pattern for efficient resource management. Implemented all aspects of the Rule of 5, emphasizing move semantics for optimized data handling. Incorporated references judiciously for smooth data access, avoiding the complexities associated with raw pointers.

πŸ” Concurrency

Introduced multithreading components, allowing parallel execution for improved performance and responsiveness. Implemented mutex strategically to synchronize thread execution, ensuring data integrity in a multi-threaded environment.

πŸš€ Program Grand Finale:

  • The program starts by prompting the user for their name.
  • The game terminates when the snake is not alive or if the user presses ESC.
  • Scores are saved into a file, and the top 10 players are displayed at the end.

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

About

A 2D Snake game using C++ and SDL

License:Creative Commons Attribution Share Alike 4.0 International


Languages

Language:C++ 75.1%Language:CMake 23.3%Language:Makefile 1.6%