Skip to content

reeceyang/tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

tetris

tetris in the terminal with python

Screen Shot 2023-10-24 at 11 07 23 PM

to run:

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-oring 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
Screen Shot 2023-10-24 at 1 12 18 PM

a screenshot of in-progress tetris development

About

tetris in the terminal with python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages