tetris.game module

class tetris.game.Game(settings: Settings)

Bases: object

Class contains main game logic and methods to draw game elements

add_score(lines_cleared: int) None

Add score for cleared lines

check_events() None

Check pygane events and react to them

check_hover() None

Checks if mouse is hovering over the buttons and changes the cursor accordingly

check_line() bool

Check if there is a line of tetrominos and delete it

Parameters:

None

Returns:

True if there is a line of tetrominos, False otherwise

Return type:

(bool)

check_lvl_up() None
check_pressed_down_movement() None

Check if down movement keys are pressed and react to them

check_pressed_rotate() None

Check if rotation keys are pressed and react to them

check_pressed_side_movement() None

Check if side movement keys are pressed and react to them

check_tetromino_above_top() bool

Check if there is a tetromino above visible top of the grid

create_game_windows() None

Create game windows

db_insert_user() None

Insert user into database

delete_line(row) None

Delete line from grid and move all tetrominos above it down

draw_end_of_game_btns() None

Draw buttons displayed at the end of the game, after loss

draw_game_window() None

Draw game window on screen

draw_grid() None

Draw grid with tetrominos on game window

draw_lvl() None

Draw score window and score on

draw_lvl_title() None

Draw score title on screen

draw_lvl_window() None

Draw score window on screen

draw_next_tetromino() None

Draw next tetromino on next tetromino window

draw_next_tetromino_title() None

Draw next tetromino title on screen

draw_next_tetromino_window() None

Draw next tetromino window on screen

draw_score() None

Draw score window and score on

draw_score_title() None

Draw score title on screen

draw_score_window() None

Draw score window on screen

game_window: Surface
game_window_rect: Rect
get_username() None
grid: list[list[int]]
init_properties() None

Initialize game properties

lines_cleared: int
lvl: int
lvl_up() None
lvl_window: Surface
lvl_window_rect: Rect
main() None

Main game loop

move_down_key_pressed: bool = False
next_game() bool

Check if user clicked on next game button or menu button

next_tetromino_grid: list[list[int]]
next_tetromino_window: Surface
next_tetromino_window_rect: Rect
print_grid() None

Print grid in console

random_tetromino() Tetromino

Return random tetromino

Returns:

Random tetromino

Return type:

(Tetromino)

score: int
score_window: Surface
score_window_rect: Rect
space_down: bool = False
username: str