Skip to content

thepeoplescoder/python--Tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris

A basic implementation of Tetris in Python.

Why Write It?

I originally wrote this in 2019, to learn the basics of pygame. The project was a little rushed, as I wanted to get a feel for how pygame works, and make something playable as soon as possible.

Requirements

  1. This game has been tested on Python 3.9, so having that version installed would be ideal. I have yet to test on other versions of Python.

    • If you're worried about this conflicting with your currently installed version of Python and you've never heard of either pyenv or pyenv-win (Windows version of pyenv), I recommend checking them out! They allow you to run multiple installations of Python side by side.
  2. Since pygame is used, make sure that you have the required pygame dependencies installed for your platform.

  3. Dependencies are managed via Pipenv, so be sure to have it installed as well.

    • I personally use pipx to install Pipenv.

How to Run

Please see the controls on how to play.
These steps assume the requirements above are met:

  1. Clone this repository and change into the directory, if you haven't done so already:

    # Cloning to ./Tetris isn't mandatory, just makes things a little easier
    git clone https://github.com/thepeoplescoder/python--Tetris Tetris
    cd Tetris
  2. Set up the environment:

    pipenv install
  3. Run main.py inside of the repository (now pipenv environment):

    pipenv run python main.py

Controls

  • Left and right arrows move the current block side to side
  • Down arrow accelerates the current block downward
  • Up arrow rotates the current block clockwise
  • Shift+Up arrow rotates the current block counterclockwise
  • P pauses/unpauses the game

Current Features

  • Lines clear with a randomized greyscale effect
  • An area showing the next block to drop is displayed
    • (it also rotates!)
  • Grid fills with random colors on game over
  • Next block area fills with random shades of purple on game over

Project Roadmap

  • Codebase modifications
    • Ultimately make the code more self-documenting
    • Add an abstraction layer between pygame and the game logic to allow for the use of other graphics/game libraries, such as arcade
  • "Beautify" the game a little bit more:
    • Label the area that displays the next block.
    • Display the score inside of the game window, instead of keeping track of it on the console.
    • Display the number of cleared lines in the game window.
    • Display the number of dropped blocks in the game window.
    • Update the display when the game is paused, such that the player knows without a doubt that the game is paused.
  • Bugs
    • Levels advance (and therefore, speed increases) based on score, instead of on number of lines cleared.

About

A Tetris clone that I started in 2019 because I was bored. It runs, but severely needs polishing. Uses pygame.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages