From 584d371ec109e29bb74fc876a4a78eec3827997f Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 17 May 2020 00:14:42 +0200 Subject: [PATCH] Optimized map respawn method --- src/game/Map.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index f39d854..07b95c0 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -31,6 +31,8 @@ class Map: # lista wszystkich entity self.entities = pygame.sprite.Group() + self.entitiesRawData = [] + self.filename = filename with open(self.filename, 'rt') as f: @@ -47,6 +49,7 @@ class Map: self.terrainDraw() for entity in self.loadEntities(self.filename): + self.entitiesRawData.append(entity) self.addEntity(entity) def loadEntities(self, mapFileName): @@ -161,10 +164,8 @@ class Map: """ for entity in self.entities.sprites(): entity.kill() - del entity - entites = self.loadEntities(self.filename) - for entity in entites: + for entity in self.entitiesRawData: self.addEntity(entity) def getEntityOnCoord(self, coord, screenRelative=False):