Skip to content

Jaredkmacho/CppND-Capstone-Tetris

Repository files navigation

CPPND: Capstone Tetris!

This is my Tetris clone Capstone project in the Udacity C++ Nanodegree Program.

This is the classic Russian puzzle game where you drop pieces strategically to complete as many lines as you can, while avoiding the pieces to stack up to the top. In this version I added the handy next piece preview and the hability to store a piece for later use(which can be easily abused!).

  • Keybindings

    • LEFT, RIGHT and DOWN arrows move the piece.
    • UP arrow will rotate the piece.
    • RIGHT CTRL will store the piece or swap it if one is already stored.
    • SPACE BAR will slam the piece down (this can be glitchy).
  • Known BUGS

    • Using SLAM when a piece is about to go down causes clipping
    • When clearing multiple non contiguous lines the shifted lines are not correctly calculated

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

Rubric requirements

Loops, Functions, I/O

  • The project accepts user input and processes the input.
    • See controller.cpp where SDL keyboard events are used to get input from the user.

Object Oriented Programming

  • The project uses Object Oriented Programming techniques.

    • See Tetris.h for classes like Tetris or Piece that encapsulates attributes and methods.
  • Classes use appropriate access specifiers for class members.

  • Classes encapsulate behavior.

    • See Piece::Rotate() method where Piece attributes are modified according to the expected behavior in Tetris.
  • Classes follow an appropriate inheritance hierarchy.

    • See controller.h where the abstract class Command is used as a base for more specific Commands, also the class Controller is composed of many Commands.
  • Overloaded functions allow the same function to operate on different parameters.

  • Derived class functions override virtual base class functions.

  • Templates generalize functions in the project.

Memory Management

  • The project makes use of references in function declarations.
    • Many methods in Tetris, Playfield and Piece class use pass-by-reference in function declarations.

TODO: Add more memory management good practices like RAII and smart pointers.

Concurrency

TODO: Add concurrency with audio events running in different threads.

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