tetris

Disclaimer: Tetris (R) is property of The Tetris Company, LLC. The proposed implementation is only for teaching purposes.


The classical game Tetris is one of the most basic game you can make. In its original version, the game was displayed on a terminal.

In this tutorial we will model the game's structure using the command line for debugging. Then we can simply add real time graphics on top.

To get a feeling for the task, it's useful to immerse yourself in it. You should consult harddrop.com, probably watch the Tetris World Championship, and some incredible feats.

Finally, you should definitely have a look at Tetris Effect. It's one of the most beautiful piece of software art ever made.

For the implementation, have a look at the Tetris Guideline.

The pieces

Pay attention to spawning rules (need a random number generator) and rotation rules.

The 7 pieces:

L J

Z S

O

T

I

Pieces are choosen at random, with some special rules to avoid situations where some pieces (like the long bar) don't drop for a time. It's not a strict requirement.

The random number generator is xor shift defined as :

The playfield

Also called well, the playfield is usually 10 width by 20 height.

Input

Gravity

Scoring

Game start / over