tetris.tetrominos module

class tetris.tetrominos.Itetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[1, 0], [1, 1], [1, 2], [1, 3]]
SPAWN_POS: list[list] = [[1, 3], [1, 4], [1, 5], [1, 6]]
TAG: str = 'I'
pos0() None

Rotates the tetromino to position 0

pos1() None

Rotates the tetromino to position 1

pos2() None

Rotates the tetromino to position 2

pos3() None

Rotates the tetromino to position 3

rotate_left() None

Rotates the tetromino left

rotate_right() None

Rotates the tetromino right

class tetris.tetrominos.Jtetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[1, 0], [2, 0], [2, 1], [2, 2]]
SPAWN_POS: list[list] = [[0, 3], [1, 4], [1, 3], [1, 5]]
TAG: str = 'J'
pos0() None

Set the tetromino to position 0

pos1() None

Set the tetromino to position 1

pos2() None

Set the tetromino to position 2

pos3() None

Set the tetromino to position 3

class tetris.tetrominos.Ltetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[2, 0], [2, 1], [2, 2], [1, 2]]
SPAWN_POS: list[list] = [[1, 3], [1, 4], [1, 5], [0, 5]]
TAG: str = 'L'
pos0() None

Set the tetromino to position 0

pos1() None

Set the tetromino to position 1

pos2() None

Set the tetromino to position 2

pos3() None

Set the tetromino to position 3

class tetris.tetrominos.Otetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[1, 1], [2, 1], [1, 2], [2, 2]]
SPAWN_POS: list[list] = [[1, 4], [1, 5], [0, 4], [0, 5]]
TAG: str = 'O'
rotate_left() None

Do nothing because the tetromino is a square

rotate_right() None

Do nothing because the tetromino is a square

class tetris.tetrominos.Stetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[2, 0], [2, 1], [1, 1], [1, 2]]
SPAWN_POS: list[list] = [[1, 3], [1, 4], [0, 4], [0, 5]]
TAG: str = 'S'
pos0() None

Set the tetromino to position 0

pos1() None

Set the tetromino to position 1

pos2() None

Set the tetromino to position 2

pos3() None

Set the tetromino to position 3

class tetris.tetrominos.Tetromino(game: Game)

Bases: object

Tetromino class for the game

LAST_COL_IDX: int = 9
NEXT_TETROMINO_GRID_POS: list[list]
SPAWN_POS: list[list]
TAG: str
check_cell_available_for_rotation(cell: list[int]) bool

Check if the cell is available for rotation

Parameters:

cell (list[int]) – Cell to check

Returns:

True if the cell is available for rotation, False otherwise

Return type:

(bool)

check_down() bool

Checks if the tetromino is at the bottom of the grid

Returns:

True if the tetromino is at the bottom of the grid, False otherwise

Return type:

(bool)

check_move_left() bool

Check if the tetromino can move left by checking if it is at the left edge of the grid or if it is touching another tetromino on the left

Returns:

True if the tetromino can move left, False otherwise

Return type:

(bool)

check_move_right() bool

Check if the tetromino can move right by checking if it is at the right edge of the grid or if it is touching another tetromino on the right

Returns:

True if the tetromino can move right, False otherwise

Return type:

(bool)

check_touch() bool

Check if the bottom of the tetromino is touching another tetromino

Returns:

True if the bottom of the tetromino is touching another tetromino, False otherwise

Return type:

(bool)

clear() None

Clears the grid from the tetromino

clear_next_tetromino_window() None

Clears the next tetromino window

hard_drop() None

Hard drops the tetromino

move_down() bool | None

Moves the tetromino down

move_left() None

Moves the tetromino left

move_right() None

Moves the tetromino right

pos: list[list]
pos0() None

Rotates the tetromino to position 0

pos1() None

Rotates the tetromino to position 1

pos2() None

Rotates the tetromino to position 2

pos3() None

Rotates the tetromino to position 3

put_on_next_tetromino_window() None

Puts the next tetromino on the next tetromino window

rotate_left() None

Rotates the tetromino left

rotate_right() None

Rotates the tetromino right

spawn() None

Set the spawn position

update_on_grid() None

Updates the grid with the new position of the tetromino

class tetris.tetrominos.Ttetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[2, 0], [2, 1], [2, 2], [1, 1]]
SPAWN_POS: list[list] = [[1, 2], [1, 3], [1, 4], [0, 3]]
TAG: str = 'T'
pos0() None

Set the tetromino to position 0

pos1() None

Set the tetromino to position 1

pos2() None

Set the tetromino to position 2

pos3() None

Set the tetromino to position 3

class tetris.tetrominos.Ztetromino(game: Game)

Bases: Tetromino

NEXT_TETROMINO_GRID_POS: list[list] = [[1, 0], [1, 1], [2, 1], [2, 2]]
SPAWN_POS: list[list] = [[0, 3], [1, 4], [0, 4], [1, 5]]
TAG: str = 'Z'
pos0() None

Set the tetromino to position 0

pos1() None

Set the tetromino to position 1

pos2() None

Set the tetromino to position 2

pos3() None

Set the tetromino to position 3