Features

  • Graphical Display: Uses `curses` to display blocks, game board, and scores.
  • Block Types: Standard Tetris blocks (I, J, L, O, S, T, Z) with different colors.
  • Game Controls: Move, rotate, drop blocks, hold blocks, and pause.
  • Scoring: Points increase by clearing rows, with higher scores for multiple rows.
  • High Score Storage: High scores are saved in `high_score.db`.

Classes and Functions

  • TetrisBoard: Manages game board, adds blocks, clears rows, and scores.
  • TetrisBlock: Represents blocks with specific shapes and colors.
  • Blocks: Initializes all predefined Tetris blocks.
  • print_board: Displays the game board and score in the terminal.
  • print_block: Renders a block at a specified position.
  • print_shadow: Shows where a block will land.
  • main: Main game loop function.

Controls

KeyAction
Left Arrow / AMove block left
Right Arrow / DMove block right
Down Arrow / SMove block down
Up Arrow / WRotate block
SpaceHard drop
HHold current block
PPause game

Installation

To play the game, ensure Python and the `windows-curses` library are installed:

pip install windows-curses

How to Play

  1. Run the game:
    python game.py
  2. Use arrow keys or WASD to move and rotate blocks.
  3. Clear rows to score points and achieve a high score, which will be saved in `high_score.db`.

High Scores

High scores are saved in `high_score.db` and updated each time a new high score is achieved.

Screenshot

Tetris Game Screenshot