37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from typing import List, Tuple
|
|
|
|
from entity.Entity import Entity
|
|
from util.ConfigurationManager import ConfigurationManager
|
|
|
|
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: Tuple, color):
|
|
super().__init__(self.__get_points(position), color)
|
|
|
|
def __get_points(self, position: Tuple) -> List:
|
|
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
|
|
|
|
shape = []
|
|
for i in range(self.WIDTH + 2):
|
|
for j in range(self.HEIGHT + 2):
|
|
if i == 0 or i == self.WIDTH + 1:
|
|
shape.append(((i, j), (i + 1, j), (i + 1, j + 1), (i, j + 1)))
|
|
elif j == 0 or j == self.HEIGHT + 1:
|
|
shape.append(((i, j), (i + 1, j), (i + 1, j + 1), (i, j + 1)))
|
|
|
|
points = []
|
|
for square in shape:
|
|
sub_points = []
|
|
for vertex in square:
|
|
point = [vertex[0] * tile_size + position[0], vertex[1] * tile_size + position[1]]
|
|
sub_points.append(point)
|
|
points.append(sub_points)
|
|
|
|
return points
|
|
|
|
|
|
|
|
|