- def update(self, dt):
- self._dt += dt
- while self._dt > self._cycle_dt:
- self._dt -= self._cycle_dt
- self._frame += 1
- self._frame %= len(self._frames)
- self.surf = self._frames[self._frame]
+def roach_by_name(world, roach_name):
+ roaches = [r for r in world.roaches if r.name == roach_name]
+ if not roaches:
+ return None
+ return roaches[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."""
+
+ def __init__(self):
+ self.smart = False
+ self.strong = False
+ self.fast = False