refactor: add base class for all game objects

This commit is contained in:
2021-06-08 12:33:58 -04:00
parent a269a532a0
commit 673c4774f2
7 changed files with 61 additions and 23 deletions

View File

@@ -1,23 +1,25 @@
from typing import List, Tuple
import pygame
from entity.Entity import Entity
from util.ConfigurationManager import ConfigurationManager
class Well: # TODO game objects base class / interface?
class Well(Entity):
WIDTH = 10 # standard tetris well width, should not be changed
HEIGHT = 20 # standard tetris well height, should not be changed
def __init__(self, position):
def __init__(self, position: Tuple):
self.points = self.__get_points(position)
def draw(self, surface):
def draw(self, surface: pygame.Surface) -> None:
well_color_hex = ConfigurationManager.configuration["color"]["border"] # TODO Should abstract out color call?
well_color = pygame.Color(well_color_hex)
for sub_points in self.points:
pygame.draw.polygon(surface, well_color, sub_points, 0)
def __get_points(self, position):
def __get_points(self, position: Tuple) -> List:
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
shape = []