from typing import Tuple import pygame from util.ConfigurationManager import ConfigurationManager class Entity: def __init__(self, points: Tuple, color: str, border_color: str = None): self.points = points self.color = color self.border_color = border_color def update(self) -> None: pass def draw(self, surface: pygame.Surface) -> None: tile_size = ConfigurationManager.configuration["engine"]["tile-size"] for square in self.points: pygame.draw.polygon(surface, pygame.Color(self.color), square, 0) if self.border_color: pygame.draw.polygon(surface, pygame.Color(self.border_color), square, max(tile_size // 6, 1)) def collide(self, entity) -> bool: for square_one in self.points: for square_two in entity.points: for i in range(4): # 4 vertices if square_one[i][0] == square_two[i][0] and square_one[i][1] == square_two[i][1]: return True return False