feat: revamp colors

This commit is contained in:
Giovani Rodriguez
2021-06-10 17:19:27 -04:00
parent 231c19c7fd
commit fc3d2fc04c
5 changed files with 42 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
from typing import List, Tuple
from pygame import mixer
import pygame
import copy
from entity.Entity import Entity
@@ -11,10 +12,11 @@ from util.ConfigurationManager import ConfigurationManager
'''
class Piece(Entity):
GRAVITY = 300 # A move down every 600 ms
GRAVITY = 300 # A move down every 300 ms
def __init__(self, shape: Tuple, position: Tuple, color: str, border_color: str):
def __init__(self, shape: Tuple, position: Tuple, color: str, inner_border_color: str, border_color: str):
super().__init__(self.__get_points(shape, position), color, border_color)
self.inner_border_color = inner_border_color
self.center = self.__get_center(shape, position)
self.piece_set_sound = mixer.Channel(2)
@@ -34,6 +36,19 @@ class Piece(Entity):
if stack and self.collide(stack):
self.revert()
def draw(self, surface: pygame.Surface) -> None:
super().draw(surface)
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
for square in self.points:
if self.inner_border_color:
vertex_one = (square[0][0] + (tile_size // 10), square[0][1] + (tile_size // 10))
vertex_two = (square[1][0] - (tile_size // 10), square[1][1] + (tile_size // 10))
vertex_three = (square[2][0] - (tile_size // 10), square[2][1] - (tile_size // 10))
vertex_four = (square[3][0] + (tile_size // 10), square[3][1] - (tile_size // 10))
new_square = (vertex_one, vertex_two, vertex_three, vertex_four)
pygame.draw.polygon(surface, pygame.Color(self.inner_border_color), new_square, max(tile_size // 6, 1))
def move(self, vector: Tuple) -> None:
# reset elapsed time if user moves down to stall gravity
if vector[1] > 0: