From 9e66c7b17935e886b9fbed0704727aacda3b0c38 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 5 Mar 2016 23:07:08 +0200 Subject: [PATCH] Fix enemy respawning. Slow rate a bit --- koperkapel/gamelib/enemy_generator.py | 2 ++ koperkapel/gamelib/level.py | 2 ++ koperkapel/levels/level1.json | 2 +- koperkapel/levels/level2.json | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/koperkapel/gamelib/enemy_generator.py b/koperkapel/gamelib/enemy_generator.py index eaf85d7..b5a1dd4 100644 --- a/koperkapel/gamelib/enemy_generator.py +++ b/koperkapel/gamelib/enemy_generator.py @@ -39,6 +39,8 @@ class EnemyGenerator(Actor): def killed(self, enemy): if enemy in self._made_enemies: self._made_enemies.remove(enemy) + # Delay next respawn so we don't flood the player with enemies + self._time_since_last_update = 0 def pause(self): self.paused = True diff --git a/koperkapel/gamelib/level.py b/koperkapel/gamelib/level.py index aed4ccc..34487af 100644 --- a/koperkapel/gamelib/level.py +++ b/koperkapel/gamelib/level.py @@ -101,6 +101,8 @@ class Level(object): def remove_enemy(self, enemy): self.enemies.remove(enemy) + for generator in self.enemy_generators: + generator.killed(enemy) def add_enemy(self, enemy, x, y): """Add an enemy to an empty floor space near x, y""" diff --git a/koperkapel/levels/level1.json b/koperkapel/levels/level1.json index 88c188a..7ec08b5 100644 --- a/koperkapel/levels/level1.json +++ b/koperkapel/levels/level1.json @@ -4390,7 +4390,7 @@ { "type": "roach", "pos": [18, 8], - "rate": 1.0, + "rate": 2.0, "max": 2 } ] diff --git a/koperkapel/levels/level2.json b/koperkapel/levels/level2.json index 99571fd..4f6dce7 100644 --- a/koperkapel/levels/level2.json +++ b/koperkapel/levels/level2.json @@ -7639,7 +7639,7 @@ { "type": "roach", "pos": [16, 9], - "rate": 1.0, + "rate": 2.0, "max": 2 } ] -- 2.34.1