1 """ Add enemies to the level as required """
4 from pgzero.actor import Actor
5 from pgzero.clock import each_tick
7 class EnemyGenerator(Actor):
8 """Generators are currently invisble, but we want the update hook."""
10 def __init__(self, info):
11 self.gen_pos = info['pos']
12 self.enemy_type = info['type']
13 self.rate = info['rate']
14 self.max_enemies = info['max']
15 self._time_since_last_update = 0
17 each_tick(self.update)
18 super().__init__(os.path.join('weapons', 'blank'))
23 self._time_since_last_update += dt
24 if self._time_since_last_update > self.rate:
25 print('A horrible monster (%s) appears' % self.enemy_type, self.gen_pos)
26 self._time_since_last_update = 0