A feature-rich terminal-based Tetris game written in C++ with customizable visual styles and smooth gameplay.
- Terminal-based gameplay with ANSI color support
- Customizable tile styles (light, clunky, clear, high)
- Standard Tetris mechanics:
- 7 different tetromino pieces (I, L, J, T, S, Z, O)
- Line clearing with scoring
- Progressive difficulty levels
- Proper rotation system
- Real-time controls with keyboard input
- Score tracking and level progression
- Cross-platform terminal support
CTetris/
├── src/
│ ├── main.cpp # Entry point and tile style definitions
│ ├── Tetris.h # Main game class declaration
│ ├── Tetris.cpp # Game logic implementation
│ ├── structures.h # Data structures (Tile, Block, Tetromino)
│ └── CORE.h # Terminal I/O utilities
├── scripts/
│ └── setup.sh # Development setup script
├── build/
│ ├── obj/ # Object files (generated)
│ └── out # Compiled executable (generated)
├── .gitignore # Git ignore rules
├── makefile # Build configuration
├── CONTRIBUTING.md # Development guidelines
└── README.md # This file
- C++ compiler with C++20 support (g++, clang++)
- Unix-like terminal (Linux, macOS, WSL)
# Clone the repository
git clone <repository-url>
cd CTetris
# Quick setup (recommended for first-time setup)
./scripts/setup.sh
# Or manual build
make
# Run with default settings
./build/out
# Run with custom board dimensions
./build/out <width> <height>The game accepts optional width and height arguments to customize the board size:
./build/out [width] [height]- width: Number of columns (default: 10)
- height: Number of rows (default: 24)
# Default 10x24 board (standard Tetris size)
./build/out
# Wide board: 15 columns, 24 rows
./build/out 15 24
# Tall board: 10 columns, 30 rows
./build/out 10 30
# Large board: 20 columns, 40 rows
./build/out 20 40
# Small board: 8 columns, 16 rows
./build/out 8 16Note: Both arguments must be provided together - you cannot specify only width or only height.
| Key | Action |
|---|---|
a |
Move left |
d |
Move right |
s |
Move down (soft drop) |
k |
Rotate left |
l |
Rotate right |
The game supports multiple visual styles for the tetromino blocks. You can modify these in src/main.cpp:
-
Light - Clean 2x2 block style
+------+ | @@ | | @@ | +______+ -
Clunky - Bold bordered style
##### # @ # ##### -
Clear - Minimalist style (default)
-
High - Decorative ASCII art style
o-----o ( .---. ) | |###| | ( '---' ) o-----o
Edit src/main.cpp and modify the Game constructor call:
// Use different tile style
Game tetris(light); // or clunky, clear, highThe Game constructor accepts these parameters:
Tile deafultTile- Visual style for blocksint width- Board width (default: 10)int height- Board height (default: 24)float inputDelay- Input responsiveness (default: 20)int borderWidth- Border thickness (default: 2)int borderHeight- Border thickness (default: 2)
- Single line: 40 × (level + 1) points
- Double line: 100 × (level + 1) points
- Triple line: 300 × (level + 1) points
- Tetris (4 lines): 1200 × (level + 1) points
| Key | Action |
|---|---|
] |
Speed up game time |
[ |
Slow down game time |
The project uses a simple Makefile:
# Clean build
rm -rf build/out
make
# Manual compilation
g++ src/main.cpp -std=c++20 -o build/out- OS: Linux, macOS, or Windows with WSL
- Compiler: g++ with C++20 support
- Terminal: ANSI color support recommended
- Dependencies: Standard C++ library only
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source. Please check with the repository owner for specific licensing terms.
Enjoy playing CTetris++! 🎮