Files

70 lines
3.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## -=:dAs:=- Tetris
### _Classic Tetris on Python + pygame with configurable blocks, colors and controls_
[![Python](https://img.shields.io/badge/Python-3.12-green)](#) [![pygame](https://img.shields.io/badge/pygame-2.6.1-orange)](#) [![PyInstaller](https://img.shields.io/badge/PyInstaller-6.16-blue)](#)
🇺🇦 [Українська версія](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
<table>
<tr>
<td align="center"><img src="images/screenshot_game.png" width="300" alt="Game" /></td>
<td align="center"><img src="images/logo_02_256x256.png" width="200" alt="Logo" /></td>
</tr>
<tr>
<td align="center"><i>Game field</i></td>
<td align="center"><i>Logo</i></td>
</tr>
</table>
### 📌 Using
#### Gameplay<a id='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<a id='ProgressivePieces' />
**_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<a id='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:=-_