refactor: move existing piece logic into class
This commit is contained in:
21
main.py
21
main.py
@@ -3,30 +3,15 @@ import pygame
|
||||
from entity.Piece import Piece
|
||||
from util.ConfigurationManager import ConfigurationManager
|
||||
|
||||
# potential color palette https://coolors.co/6495ed-ee6352-59cd90-fac05e-f79d84
|
||||
TILE_SIZE = 10 # TODO define tile size in config
|
||||
|
||||
def draw(screen):
|
||||
# draw window bg
|
||||
bg_color = pygame.Color(ConfigurationManager.configuration["color"]["cornflower-blue"])
|
||||
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)]
|
||||
fire_opal = ConfigurationManager.configuration["color"]["fire-opal"]
|
||||
|
||||
# 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))
|
||||
|
||||
fire_opal = pygame.Color(ConfigurationManager.configuration["color"]["fire-opal"])
|
||||
pygame.draw.polygon(screen, fire_opal, j_transalation_points, 0)
|
||||
j_piece = Piece(Piece.J_SHAPE, (100, 100), fire_opal)
|
||||
j_piece.draw(screen)
|
||||
|
||||
# update display
|
||||
pygame.display.update()
|
||||
|
||||
Reference in New Issue
Block a user