Hack keyboard behaviour to be different. Also incidently allow rotating in place
[koperkapel.git] / koperkapel / gamelib / enemy_generator.py
1 """ Add enemies to the level as required """
2
3 import os
4 from pgzero.actor import Actor
5 from pgzero.clock import each_tick
6
7 class EnemyGenerator(Actor):
8     """Generators are currently invisble, but we want the update hook."""
9
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
16         self.paused = False
17         each_tick(self.update)
18         super().__init__(os.path.join('weapons', 'blank'))
19
20     def update(self, dt):
21         if self.paused:
22             return
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
27
28     def pause(self):
29         self.paused = True
30
31     def unpause(self):
32         self.paused = False