From 107bd0d8f7e20793823450076439b8080e01f868 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Thu, 14 May 2020 11:32:13 +0200 Subject: [PATCH] Changed constructor --- src/entities/Entity.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/entities/Entity.py b/src/entities/Entity.py index 8060c4d..f618e7a 100644 --- a/src/entities/Entity.py +++ b/src/entities/Entity.py @@ -12,12 +12,13 @@ class Entity(pygame.sprite.Sprite): pygameTimer = pygame.time.Clock() - def __init__(self, texture, size, pos): + def __init__(self, texture, size, pos, screenRelative=True): """ Create an entity. :param texture: Path to a file with texture :param size: Size in px :param pos: Position tuple + :param screenRelative: Is the pos arg relative to the screen or not? """ super().__init__() self.image, self.rect = self.getTexture(texture, size) @@ -25,11 +26,13 @@ class Entity(pygame.sprite.Sprite): # Screen class sets this field when you want to draw a sprite self.mapOffset = 0 # Relative coords - self.x = pos[0] - self.y = pos[1] + self.x = 0 + self.y = 0 # Rect has entities' absolute coords - self.rect.x = pos[0] - self.rect.y = pos[1] + self.rect.x = 0 + self.rect.y = 0 + # Set the initial coords + self.setCoords(pos, screenRelative) # Unique ID self.id = self.setNewId()