-class RoachActor(OrientatedSurfActor):
- def __init__(self, frames):
- self._frames = frames
- self._frame = random.randint(0, len(frames) - 1)
- self._dt = 0
- self._cycle_dt = 0.2
- each_tick(self.update)
- super().__init__(surf=frames[self._frame], angle=0)
+def next_roach_name(world):
+ roach_names = [x['name'] for x in world.roaches]
+ for cand in NAMES:
+ if cand not in roach_names:
+ return cand
+
+
+def build_roach(world, name=None, health=5, **kw):
+ if name is None:
+ name = next_roach_name(world)
+ if name is None:
+ return
+ roach = {
+ "name": name,
+ "health": health,
+ }
+ roach.update(kw)
+ return roach
+
+
+class WorldRoach(object):
+ """A roach proxy with no properties for display on the game level."""