https://github.com/reeceyang/tetris
tetris in the terminal with python
https://github.com/reeceyang/tetris
Last synced: 3 months ago
JSON representation
tetris in the terminal with python
- Host: GitHub
- URL: https://github.com/reeceyang/tetris
- Owner: reeceyang
- Created: 2023-10-25T02:11:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-25T04:28:16.000Z (over 2 years ago)
- Last Synced: 2025-12-26T20:10:43.938Z (7 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tetris
tetris in the terminal with python

to run:
```bash
python3 tetris.py
```
controls: `left`, `right`, and `down` to move the current piece. `space` to hard drop. `z` and `x` to rotate. `c` to hold.
all pieces are represented by tuples of integers: in binary a 1 indicates the piece is in that cell and a 0 indicates that it isn't. this lets us do many tetris operations through bit operations
the `Tetris` object is designed to allow for custom pieces and board sizes.
i used the `curses` library for user input and display.
possible extensions:
- game over checking is unimplemented. all the functionality for this theoretically exists but i couldn't get curses to print the game over message
- adding in different colors for different pieces. i had a plan to do this by keeping $n$ versions of the board for each color, then bitwise-`or`ing all the color boards together to do the full board computations
- rotating pieces (and input in general) feels somewhat funky compared to "real" tetris
- add in the bag system for choosing the next piece. right now the next piece is chosen at random
- adding in sound effects and music

_a screenshot of in-progress tetris development_