From 18c488ac489b4d4bb9db9360e80c47d6dda09859 Mon Sep 17 00:00:00 2001 From: Giovani Date: Tue, 8 Jun 2021 14:07:03 -0400 Subject: [PATCH] refactor: reference tile size using config --- Tetris.py | 4 ++-- entity/Entity.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tetris.py b/Tetris.py index c3d7070..01c1cf1 100644 --- a/Tetris.py +++ b/Tetris.py @@ -79,9 +79,9 @@ class Tetris: # draw all game objects if self.well: - self.well.draw(self.screen, self.tile_size) # TODO Should it be doing taking in tile_size? + self.well.draw(self.screen) if self.current_piece: - self.current_piece.draw(self.screen, self.tile_size) + self.current_piece.draw(self.screen) # update display pygame.display.update() diff --git a/entity/Entity.py b/entity/Entity.py index 65491a4..e7ace87 100644 --- a/entity/Entity.py +++ b/entity/Entity.py @@ -1,6 +1,8 @@ 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 @@ -10,7 +12,9 @@ class Entity: def update(self) -> None: pass - def draw(self, surface: pygame.Surface, tile_size) -> None: + 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: