66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
import pygame
|
|
from entity.tetromino import tetromino
|
|
|
|
# window properties
|
|
WIN_WIDTH = 800
|
|
WIN_HEIGHT = 600
|
|
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():
|
|
pygame.init()
|
|
|
|
screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
|
|
clock = pygame.time.Clock()
|
|
loaded_icon = pygame.image.load(WIN_ICON)
|
|
|
|
pygame.display.set_caption(WIN_TITLE)
|
|
pygame.display.set_icon(loaded_icon)
|
|
|
|
is_running = True
|
|
while is_running:
|
|
clock.tick(FPS)
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
is_running = False
|
|
|
|
draw(screen)
|
|
|
|
pygame.quit()
|
|
|
|
# start main function
|
|
main() |