from Code.Config import GeneralConfig, SquareConfig import math from Code.UI import Square from Code.UI.Square import Square class Field: def __init__(self): self.width = math.trunc(GeneralConfig.width / SquareConfig.width) + 2 self.height = math.trunc(GeneralConfig.height / SquareConfig.height) + 2 self.field_shift = -10 self.squares = self._creat_squares() def _creat_squares(self): squares = [ [Square(x_pos=j * SquareConfig.width + self.field_shift, y_pos=i * SquareConfig.height + self.field_shift) for i in range(self.height)] for j in range(self.width)] return squares def update_squares(self,squares): self.squares=squares def draw_squares(self, window): for x in self.squares: for y in x: y.draw(window)