Skip to content

iScsc/TetrisPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tetris modular 2000

Introduction

Upper text
Bottom text

Since its beginning, mankind has always played games, and Tetris, is one of those games, even if it's recent, it's still relevant and played by many people, even bypassing cultures differences

TODO List

  • Chose terrain size
  • A proper graphic interface
  • A score system
  • Next piece coming window
  • Chose controls (maybe)
  • Sound support (maybe)
  • Line Suppression
  • Read the config files
  • Have it to work

Plan


  1. Requierments
    1. Python version
    2. Librairies
  2. The Game
    1. Command
    2. How to play
  3. User customization
    1. Import custom pieces
    2. Chose all the colors used
    3. Chose the size of the terrain
    4. Change the controls (Maybe)
    5. Chose how the pieces are selected (Maybe)

Requierments


Python version

Coded using Python 3.9
(TODO check) 3.8 might be enough

Librairies

Some librairies such as :

The Game


It's a basic Tetris, for now at least, but I wanted it to be as flexible as possible, so there are are few functionnalities that differ from the original Tetris, detailed in User customization
Score not implemented yet
Better graphic interface to come
T-spin works

How to play

To play, just enter python main.py in something that receives commands and understands python such as Linux terminal or Windows Powershell

How it works

As said in the librairies section, it uses the numpy librairy, and it is used a lot to compute collisions between pieces.
More precisely, the game uses the numpy masks and array check to find if there is any collision happening in the next wanted move, to recognize, the collision array has a structure composed of 0 where there is nothing, 1 for a piece and -2 outside, so if there are -1 or 2 in the array it won't move.

User customization


Import custom pieces

Yes, indeed you can create your own pieces to play with them. It's not that hard but you have to respect a few rules to avoid the code to eplode !

  • Respect the syntax, look closely to the existing pieces for templates
  • The piece mask must be a square, so maybe add spaces at the end
  • Keep in mind that the center square will be the center of rotation of the piece
  • For new color for pieces, check the color implementation doc below, and put the index of the color, not the color itself

To implement your pieces, all you have to do is to edit the file patterns.txt in the config folder
If it's still unclear, lets have an example :
For the T piece, the mask is [ # :###: ], we can see that # represents a block, a space nothing, and : means to go on the next layer. We have a third layer to have a squared piece and this layer is on the bottom, otherwise the rotation would be pretty strange.

Chose colors

In this game you can also change colors ! Wow such amazing features aren't they !
To do so you have to go and edit the config.cfg in the config folder with any notepad application
There are some fields non-related to colors so scroll a bit until you find a huge list of colors, note that by default the 0-16 indexes are reserved for game use, so for pieces colors, use the indexes from 17 to 255.
As exposed, there are 256 indexes for color, so you have a lot of choices, each is associated with a color in hexadecimal, if you want to convert your rgb color into hexa, you can go here

Chose terrain size

TODO

Change controls

TODO

Change piece selector

TODO

Releases

No releases published

Packages

No packages published

Languages