Tetris

Ritchie Ly | CPE 471 | Professor Shinjiro Sueda | Spring 16

The Game

"Tetriminos" are game pieces shaped like tetrominoes, geometric shapes composed of four square blocks each. A random sequence of Tetriminos fall down the playing field (a rectangular vertical shaft, called the "well" or "matrix"). The objective of the game is to manipulate these Tetriminos, by moving each one sideways (if the player feels the need) and rotating it by 90 degree units, with the aim of creating a horizontal line of ten units without gaps. When such a line is created, it disappears, and any block above the deleted line will fall.

Source: https://en.wikipedia.org/wiki/Tetris

Moves

Left = ‘u’

Slow Drop = ‘i

Right = ‘o’

Rotate Left = ‘8’

Rotate Right = ‘9’

Quick Drop = Spacebar

The Board
The board is based on the tetris standard, having the playing field being 10 cells wide and 20 cells high, with a 3 row initial field on top for pieces to appear in. Cells around the playing field are filled with a cement-type block, which are unpassable and un-clearable. A wall of cement-type blocks also lines the back of the play field, for design purposes.

Renders

Each render of a cell is done with a cube.obj file, courtesy of http://people.sc.fsu.edu/~jburkardt/data/obj/cube.obj. The block textures used were courtesy of https://github.com/obneq/tetris/tree/master/textures.

The Pieces

The Pieces, also known as tetriminos, consist of 4 cells. These pieces are made from 3x3 matrixes, with the exception of the I piece (4x4 matrix) and the square piece (2x2 matrix). These dimensions are based off of the rotational pivots on each piece.

Collisions
Pieces are not allowed to leave the board, nor move through any dead piece. Collision checking ensures these events do not occur.

Rotations
Rotations are applied to piece matrixes. Right rotations are done by transposing the tetrimino matrix, then reversing the rows. Left rotations are done by transposing the tetrimino matrix, then reversing the columns.

[0][1][0]           [0][1][0]           [0][1][0]

[1][1][1]    =>     [1][1][0]    =>     [1][1][1]

[0][0][0]           [0][1][0]           [0][0][0]

Transpose          Reverse Row

Kick Backs
Pieces are allowed kickbacks from walls. Rotating into a wall pushes a piece back while still allowing rotation.

Quick Drop
Quick drop allows the falling tetrimino to be placed on the lowest spot available in its current column.