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
Key | Action |
---|---|
Left Arrow / A | Move block left |
Right Arrow / D | Move block right |
Down Arrow / S | Move block down |
Up Arrow / W | Rotate block |
Space | Hard drop |
H | Hold current block |
P | Pause game |
Installation
To play the game, ensure Python and the `windows-curses` library are installed:
pip install windows-curses
How to Play
- Run the game:
python game.py
- Use arrow keys or WASD to move and rotate blocks.
- 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.