Files
tetri5/main.py

65 lines
1.9 KiB
Python

import pygame
from entity.Piece import Piece
from util.ConfigurationManager import ConfigurationManager
# potential color palette https://coolors.co/6495ed-ee6352-59cd90-fac05e-f79d84
FIRE_OPAL = (238, 99, 82) # TODO define colors in config
TILE_SIZE = 20 # TODO define tile size in config
def draw(screen):
# draw window bg
bg_color = pygame.Color(ConfigurationManager.configuration["window"]["background-color"])
screen.fill(bg_color)
# TODO move piece logic into class
# 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():
ConfigurationManager.load()
pygame.init()
win_width = ConfigurationManager.configuration["window"]["width"]
win_height = ConfigurationManager.configuration["window"]["height"]
win_icon = ConfigurationManager.configuration["window"]["icon"]
win_title = ConfigurationManager.configuration["window"]["title"]
fps = ConfigurationManager.configuration["engine"]["fps"]
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()