feat: define preliminary piece logic
This commit is contained in:
10
entity/tetromino.py
Normal file
10
entity/tetromino.py
Normal 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
23
main.py
@@ -1,4 +1,5 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
from entity.tetromino import tetromino
|
||||||
|
|
||||||
# window properties
|
# window properties
|
||||||
WIN_WIDTH = 800
|
WIN_WIDTH = 800
|
||||||
@@ -7,13 +8,35 @@ WIN_ICON = "img/tetris_icon.png"
|
|||||||
WIN_TITLE = "Tetris"
|
WIN_TITLE = "Tetris"
|
||||||
WIN_BG_COLOR = (100, 149, 237) # cornflower blue, RGB
|
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
|
# engine properties
|
||||||
FPS = 60
|
FPS = 60
|
||||||
|
|
||||||
|
# other
|
||||||
|
TILE_SIZE = 20
|
||||||
|
|
||||||
def draw(screen):
|
def draw(screen):
|
||||||
# draw window bg
|
# draw window bg
|
||||||
screen.fill(WIN_BG_COLOR)
|
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()
|
pygame.display.update()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user