Verteiltesystheme/Code/UI/Field.py

30 lines
873 B
Python
Raw Normal View History

2022-03-20 09:47:49 +01:00
from Code.Config import GeneralConfig, SquareConfig
import math
from Code.UI import Square
from Code.UI.Square import Square
class Field:
def __init__(self):
2022-03-20 13:22:19 +01:00
self.width = math.trunc(GeneralConfig.width / SquareConfig.width) + 2
self.height = math.trunc(GeneralConfig.height / SquareConfig.height) + 2
self.field_shift = -10
2022-03-20 09:47:49 +01:00
self.squares = self._creat_squares()
def _creat_squares(self):
2022-03-20 13:22:19 +01:00
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)]
2022-03-20 09:47:49 +01:00
return squares
2022-03-20 13:22:19 +01:00
def update_squares(self,squares):
self.squares=squares
2022-03-20 09:47:49 +01:00
def draw_squares(self, window):
for x in self.squares:
for y in x:
y.draw(window)