From 0f3d8429351c5a277303b3a935288c8e6ae3bdb0 Mon Sep 17 00:00:00 2001 From: Giovani Rodriguez Date: Wed, 2 Jun 2021 19:33:33 -0400 Subject: [PATCH] feat: define preliminary piece logic --- entity/tetromino.py | 10 ++++++++++ main.py | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 entity/tetromino.py diff --git a/entity/tetromino.py b/entity/tetromino.py new file mode 100644 index 0000000..d818fe9 --- /dev/null +++ b/entity/tetromino.py @@ -0,0 +1,10 @@ +import pygame + +''' + For information on the Tetris piece Tetromino go here: + https://tetris.fandom.com/wiki/Tetromino +''' +class tetromino: + + def __init__(self): + pass \ No newline at end of file diff --git a/main.py b/main.py index c2d8c40..d2f2dd6 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import pygame +from entity.tetromino import tetromino # window properties WIN_WIDTH = 800 @@ -7,13 +8,35 @@ WIN_ICON = "img/tetris_icon.png" WIN_TITLE = "Tetris" WIN_BG_COLOR = (100, 149, 237) # cornflower blue, RGB +# potential color palette https://coolors.co/6495ed-ee6352-59cd90-fac05e-f79d84 +FIRE_OPAL = (238, 99, 82) + # engine properties FPS = 60 +# other +TILE_SIZE = 20 + def draw(screen): # draw window bg screen.fill(WIN_BG_COLOR) + # draw j tetromino? + j_points = [(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (3, 2), (2, 2), (2, 1), (1, 1), (0, 1)] + + # scale piece + j_scaled_points = [] + for point in j_points: + j_scaled_points.append((point[0] * TILE_SIZE, point[1] * TILE_SIZE)) + + # move piece diagonally + j_transalation_points = [] + for point in j_scaled_points: + j_transalation_points.append((point[0] + TILE_SIZE, point[1] + TILE_SIZE)) + + pygame.draw.polygon(screen, FIRE_OPAL, j_transalation_points, 0) + + # update display pygame.display.update() def main():