Skip to content

yan99033/CppND-Capstone-Pong

Repository files navigation

CPPND: Capstone Pong Game

Pong is a classic 2D table tennis-themed video game, which consists of two vertically moving paddles and a ball that bounces off the window edges and the inner side of the paddles.

The keyboard controls for the paddle are as follows:

  • 'q' / 'a': up/down for the left paddle
  • 'p' / 'l': up/down for the right paddle

Two players compete against each other by preventing the ball from moving beyond their paddle. The game ends when a player reaches 10 points.

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: ./PongGame.

NOTE: Segmentation fault might occur due to font not being loaded properly, in which case you want to make sure that SDL2_ttf is used during compilation and/or set the filenames to absolute paths (renderer.h Line 54 and 55).

Rubric requirements

  1. Loops, Functions, I/O

    • The project accepts user input and processes the input (see Controller::GetKeyboardInputs).
  2. Object Oriented Programming

    • The project uses Object Oriented Programming techniques.
    • Classes use appropriate access specifiers for class members.
    • Class constructors utilize member initialization lists.
    • Classes abstract implementation details from their interfaces (see Renderer class).
    • Classes follow an appropriate inheritance hierarchy (see GameObject, Paddle and Ball class).
    • Overloaded functions allow the same function to operate on different parameters (see Renderer::Render functions).
    • Derived class functions override virtual base class functions (see Paddle::Move and Ball::Move).
  3. Memory Management

    • The project follows the Rule of 5 (see Score class).
    • The project uses smart pointers instead of raw pointers (See Game::left_paddle_ and Game::right_paddle_).
  4. Concurrency

    • The project uses multithreading (see Game::Run in which 3 threads is running in parallel alongside the game thread).
    • A mutex or lock is used in the project (see Controller, CollisionEngine, Paddle, and Ball class).
    • A condition variable is used in the project (see collision_engine.h SignalQueue class).

Acknowledgement

This project is based on the starter repo for the Capstone project in the Udacity C++ Nanodegree Program.

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 classic 2D Atari game using C++ and SDL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published