From 264aa2969c69348b94a4c45348c18f60aac0bb50 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sat, 16 May 2020 12:47:40 +0200 Subject: [PATCH] Added respawn method --- src/game/Map.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index 66ae654..503239d 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -31,7 +31,9 @@ class Map: # lista wszystkich entity self.entities = pygame.sprite.Group() - with open(filename, 'rt') as f: + self.filename = filename + + with open(self.filename, 'rt') as f: for line in f: self.terrain.append(line) @@ -44,7 +46,7 @@ class Map: self.terrainDraw() - for entity in self.loadEntities(filename): + for entity in self.loadEntities(self.filename): self.addEntity(entity) def loadEntities(self, mapFileName): @@ -153,6 +155,18 @@ class Map: self.screen.addSprite(object, Locations.MAP) self.collidables.add(object) + def respawn(self): + """ + Respawns all entities on the map. + """ + for entity in self.entities.sprites(): + entity.kill() + del entity + + entites = self.loadEntities(self.filename) + for entity in entites: + self.addEntity(entity) + def getEntityOnCoord(self, coord, screenRelative=False): """ Get an entity on a given coordinate