Skip to main content

A tetris game runs in the terminal

Project description

gameplay
English | 中文

Tetris Terminal🎮

A terminal-based Tetris game written in Python using the curses library.

License: MIT Python 3.9+

Features

  • Modern Tetris design following the Tetris Design Guideline
    • Extended Placement
    • Next Piece Preview
    • SRS System
    • Piece Holding
    • Shadow Piece
    • Modern Scoring System
    • Modern Level System

Platform Support

Based on Python's curses module:

  • Linux/macOS: Works out of the box
  • ✅️ Windows: With windows-curses
  • Can run on basically any terminal setup, even a linux tty.

Installation & Usage

pip install tetris-terminal
tetris

Controls

Key Action
a, Move left
d, Move right
w, ,x Rotate cw
z Rotate ccw
s, Soft drop
space Hard drop
c Hold
p Pause
q Quit game

CLI Options

Option Description
--generate-config Generate a default config file and exit
--disable-config Ignore config file and run with built-in defaults
--version Show version and exit

Configuration

On first run, or via tetris --generate-config, a configuration file is created at:

Platform Path
Linux ~/.config/tetris-terminal/config.json
macOS ~/Library/Application Support/tetris-terminal/config.json
Windows %APPDATA%/tetris-terminal/config.json

The config file references a JSON Schema for editor autocompletion and validation. All fields are optional — missing keys fall back to their defaults.

display

Visual appearance of the game board.

Key Default Description
empty_cell " " Empty cell character
solid_cell "██" Filled cell character
shadow_cell "░░" Shadow piece character
bd_v "│" Border vertical
bd_h "─" Border horizontal
bd_tl "╭" Border top-left
bd_tr "╮" Border top-right
bd_bl "╰" Border bottom-left
bd_br "╯" Border bottom-right
bd_vr "├" Border T-right
bd_vl "┤" Border T-left
bd_hb "┬" Border T-bottom
bd_ht "┴" Border T-top

timing

Frame rate and animation settings.

Key Default Description
fps 30 Frames per second
clear_anim_flash_interval 0.05 Line clear flash interval (seconds)
clear_anim_duration 0.3 Line clear animation duration (seconds)

game_rules

Gameplay parameters.

Key Default Description
max_lock_down_move_count 15 Max moves before piece locks down
time_attack_duration 120 Time Attack mode duration (seconds)

License

MIT License - see LICENSE for details.

Acknowledgements

Idea from tinytetris (a C implementation).

Going to be implemented(Maybe)

  1. sound
  2. ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tetris_terminal-0.2.6.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tetris_terminal-0.2.6-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file tetris_terminal-0.2.6.tar.gz.

File metadata

  • Download URL: tetris_terminal-0.2.6.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for tetris_terminal-0.2.6.tar.gz
Algorithm Hash digest
SHA256 eacf2d97d3d86e7c449ee36dca827f5d5f9b4547240ca3fede958008ca771dba
MD5 9b1911405dc84e9e137f8d111d8c338a
BLAKE2b-256 12d155bdb4fe057abc9bd6d1942ee7163db07d8a4c5a2c153243b26c7af8ed52

See more details on using hashes here.

File details

Details for the file tetris_terminal-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for tetris_terminal-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca235e0690cb8c3e8209724f4c0979a7f6c94cd05b6f7ec325e25d5c510742c
MD5 eec8495c2793891fcb3ae8d7ec18500c
BLAKE2b-256 9baedb185cd0361bbc411126a9632f62ff37558c324dcf04d26a300cdcffe193

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page