This is a simple implementation of the classic Tetris game using C++. The game is played in the terminal, and it features very basic Tetris mechanics such as rotating and moving pieces, clearing lines.
- Download and Play
- Requirements to Code
- Building the Project
- Running the Game
- Controls
- Features
- Future Improvements
- License
- Contributing
Visit the project’s Releases page and download the binary that corresponds to your operating system. Once downloaded, execute the file from your terminal to begin the game.
Warning
Important
🔒 Security Notice: Precompiled binaries may be flagged by your operating system’s security mechanisms because they are unsigned.
-
Windows: If a SmartScreen warning appears, select “More info” and then “Run anyway.”
-
MacOS: You may need to remove the quarantine attribute:
xattr -d com.apple.quarantine /path/to/tetris
-
Linux: Grant execute permission before running:
chmod +x /path/to/tetris
- A C++ compiler (like g++)
- Terminal or command-line interface (ANSI support for better visuals)
- Bazel build system (optional, but recommended for building the project)
- C++20 or later
- Clone the repository:
git clone https://github.com/itssimmons/tetris.cpp.git
cd tetris.cpp- Build the project using Bazel:
bazel build //tetris:tetrisAfter building the project, you can run the game using the following command:
bazel run //tetris:tetris- ←: Move piece left
- →: Move piece right
- ↓: Soft drop piece
- ↑: Rotate piece (clockwise)
- space: Drop piece instantly
- esc: Exit the game
- Z: Rotate piece (counter-clockwise)
- X: Rotate piece (clockwise)
- Basic Tetris mechanics (moving, rotating, and dropping pieces).
- Line clearing.
- Game over condition when pieces stack up to the top of the playfield.
- The size of the board is based on the size of the terminal window, allowing for a dynamic play area.
- Frame rate of 30 FPS for smooth gameplay in a terminal environment.
- Piece generation using "seed" based randomization for reproducibility.
- ANSI escape codes for better visuals in the terminal.
- Implementing a scoring system.
- Accelerating piece speed as the game progresses.
- Implementing a hold piece feature.
- Implementing a next pieces preview.
- Adding sound effects (if possible in a terminal environment).
- Spinning mechanics and T-spin recognition.
- CLI options for customizing the game (e.g., board size, piece colors, base speed, etc...).
This project is licensed under the MIT License - see the LICENSE file for details
Contributions are welcome! If you have any ideas for improvements or want to fix bugs, feel free to submit a pull request or open an issue.
