feat: define preliminary piece logic

This commit is contained in:
2021-06-02 19:33:33 -04:00
parent 9f053a4b09
commit e5ea8988c8
2 changed files with 33 additions and 0 deletions

10
entity/tetromino.py Normal file
View File

@@ -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

23
main.py
View File

@@ -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():