From 2bf0ed035bdfc9a30d29bd0425df3039bc9cf41a Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Thu, 14 May 2020 11:15:27 +0200 Subject: [PATCH] Added map coord offset --- src/entities/Entity.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/entities/Entity.py b/src/entities/Entity.py index 12fa168..91efdb8 100644 --- a/src/entities/Entity.py +++ b/src/entities/Entity.py @@ -22,6 +22,8 @@ class Entity(pygame.sprite.Sprite): super().__init__() self.image, self.rect = self.getTexture(texture, size) self.image.set_colorkey((255, 255, 255)) + # 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] @@ -55,8 +57,8 @@ class Entity(pygame.sprite.Sprite): self.rect.x, self.rect.y = coords else: self.x, self.y = coords - self.rect.x = coords[0] * self.rect.w # TODO: Add screen offset - self.rect.y = coords[1] * self.rect.h # TODO: Add screen offset + self.rect.x = coords[0] * self.rect.w + self.mapOffset + self.rect.y = coords[1] * self.rect.h @staticmethod def setNewId():