Fix enemy respawning. Slow rate a bit
authorNeil <neil@dip.sun.ac.za>
Sat, 5 Mar 2016 21:07:08 +0000 (23:07 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 5 Mar 2016 21:18:39 +0000 (23:18 +0200)
koperkapel/gamelib/enemy_generator.py
koperkapel/gamelib/level.py
koperkapel/levels/level1.json
koperkapel/levels/level2.json

index eaf85d76eb633c9194ef8a08e7842b86979ffe6e..b5a1dd40969f363f9ab25dec2f1f6b1c0a6a8dbc 100644 (file)
@@ -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
index aed4cccb880b88b48cd33ba33e6afe0abcba9663..34487af920d67e5ce59f97ddc5b8d0d1bb085fa2 100644 (file)
@@ -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"""
index 88c188a315ef1de3391cddc1ba35f7a0d98dbcb7..7ec08b52b4d24e6cebc67b0e72ba57f1d91a5350 100644 (file)
       {
        "type": "roach",
        "pos": [18, 8],
-       "rate": 1.0,
+       "rate": 2.0,
        "max": 2
       }
    ]
index 99571fd75658e48bfeedb3b6bae06d1e07b82117..4f6dce755097ddebe3d96fb6c859edfa8e2cb1c5 100644 (file)
       {
        "type": "roach",
        "pos": [16, 9],
-       "rate": 1.0,
+       "rate": 2.0,
        "max": 2
       }
    ]