Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.46 KB

File metadata and controls

48 lines (33 loc) · 1.46 KB

PYTRIS

A simple 'Tetris'-Clone in Python with PyGame.

Features

-Score Counter
-Blocks can be rotated
-Lines get deleted if they are full of blocks
-Blocks spawn in random colours
-Game restarts when space is pressed on 'Game Over'

Controls

-Space:         Blocks fall
-Left / Right:  Move Blocks
-Up / Down:     Rotate Blocks

Function Documentation

setup_pygame()

Initializes PyGame. Creates the screen and clock variables. Sets the window title.

init_world()

Initializes the 2D List where the block data is stored. The active element is NOT stored inside of this list. It contains only static blocks.

create_block()

Creates a new block. A new block is created at the start of the game and when a block cant move anymore.

The Shape of the block and its colour is selected via random choice and colour.

rotate_active()

Rotates a active element around its centerpoint. Centerpoint is calculated by the average of all positions. Rotation only happens if the object doesnt collide with existing blocks, or the world boundary.

move active()

Moves the active element into a specified direction. Moving only happens if the target location is valid.

update_world()

Adds the current active element to the static world.

draw_world()

Draws all pytris blocks of update_worldthe world to the screen.

draw_active()

Draws only the active element to the screen.

run_game()

Contains the game loop.