def __init__(self):
super().__init__()
+ self.actors.add_layer("roaches", level=10)
self._roach_actors = {}
def update(self, world, dt):
for i, roach in enumerate(world.roaches):
- if roach["name"] in self._roach_actors:
- actor = self._roach_actors[roach["name"]]
+ if roach.name in self._roach_actors:
+ actor = self._roach_actors[roach.name]
else:
actor = TextButton("%s [%s]" % (
- roach["name"],
+ roach.name,
", ".join("%s=%s" % kv for kv in sorted(
- roach["attributes"].items()),
+ roach.attributes.items()),
)))
- self._roach_actors[roach["name"]] = actor
- self.actors.add(actor)
+ self._roach_actors[roach.name] = actor
+ self.actors.add(actor, layer="roaches")
# TODO: remove missing roaches
actor.pos = (300, 100 + i * 100)