From aec4ddf2d353c9b5773946862a33f2c84c0bce0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 5 Apr 2020 21:48:43 +0200 Subject: [PATCH] Add method returning specified screen part width --- src/game/Screen.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/game/Screen.py b/src/game/Screen.py index 7e59ebc..ee93aab 100644 --- a/src/game/Screen.py +++ b/src/game/Screen.py @@ -7,6 +7,13 @@ import pygame MARGIN = 300 +# screen locations enum +class Locations(Enum): + RIGHT_UI = 1 + LEFT_UI = 2 + MAP = 3 + + class Screen: def __init__(self, gameObject, windowConfig): self.gameObject = gameObject @@ -46,9 +53,10 @@ class Screen: sprite.rect.x += self.mapCoord self.gameObject.spritesList.add(sprite) - -# screen locations enum -class Locations(Enum): - RIGHT_UI = 1 - LEFT_UI = 2 - MAP = 3 + def getUiWidth(self, location: Locations): + if location is Locations.RIGHT_UI: + return self.winX - (self.mapCoord + self.mapSize) + elif location is Locations.LEFT_UI: + return self.mapCoord + elif location is Locations.MAP: + return self.mapSize