## -=:dAs:=- Tetris
### _Classic Tetris on Python + pygame with configurable blocks, colors and controls_
[](#) [](#) [](#)
πΊπ¦ [Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Π²Π΅ΡΡΡΡ](README_ua.md)
### π‘ Purpose
A desktop Tetris game where the set of pieces, their colors, the unlock score for each piece, the field width, block size, colors and keys are described in JSON files β so the game can be extended with new shapes without touching the code.
### π Features
- [Gameplay](#Gameplay) β falling pieces, rotation, line clearing, score and lines counter, next-piece preview
- [Progressive pieces](#ProgressivePieces) β 23 shapes, new ones unlock as the score grows
- [Configuration](#Configuration) β keys, colors, field width, block size and speed mode in JSON
- Pause, restart and exit confirmation dialog (mouse or Y/N keys)
### β Advantages
- **Data-driven shapes** β any new piece is a few lines of JSON: name, color, minimal score and a list of rotations.
- **Safe defaults** β committed `*_000.json` defaults are used automatically when local configs are absent.
- **Runs from anywhere** β configs are resolved next to the script or the built executable, not the current directory.
- **Clear config errors** β broken JSON or a missing key stops the game with a message naming the file and key.
### π± Screenshots
 |
 |
| Game field |
Logo |
### π Using
#### Gameplay
**_Standard Tetris rules on a 20-row field_**
- `β` / `β` β move, `β` β rotate, `β` β drop one row
- `P` β pause, `R` β restart, `Esc` β exit (with confirmation)
- Score for cleared lines at once: 1 β 100, 2 β 300, 3 β 500, 4 β 800
- The next piece is always different from the current one
#### Progressive pieces
**_The higher the score, the more varied the pieces_**
- 8 base shapes (`configs/blocks.json`): Square, Line, Line3 and L from the start; J from 900, S from 1000, Z and T from 2500 points
- 15 additional shapes (`configs/blocks_ADD.json`, optional): Dot, U, Corner, X, P, F and others, unlocked from 3500 up to 30000 points
- Above 5000, 10000 and 15000 points the falling speed changes
#### Configuration
**_All settings live in `configs/`_**
- `config.json` β keys (pygame key names, e.g. `K_LEFT`), controls help text, colors, `store_width` (field width in blocks), `block_size` (pixels), `high_score_inc_speed`
- `high_score_inc_speed`: `false` β the game speeds up as the score grows, `true` β it slows down
- `blocks.json` / `blocks_ADD.json` β pieces: `name`, `color` `[r, g, b]`, `min_score`, `shapes` (list of clockwise rotations, 0/1 matrices); at least one piece must have `min_score` 0
- If a local file is missing, its `*_000.json` default is used
### π Running
Requirements: Python 3.12, pygame 2.6.
```shell
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/python das_tetris_gui.py # start the game
.venv/bin/python -m unittest discover -s tests -v # run tests
.venv/bin/pip install pyinstaller
.venv/bin/pyinstaller --onefile das_tetris_gui.py # build a single executable into dist/
```
The executable reads configs from a `configs/` folder located next to it.
###### _Made by -=:dAs:=-_