Move roaches to the roach layer.
[koperkapel.git] / koperkapel / scenes / roaches.py
index aab4a9a2be480a310f5e820a8abf2beb77f705bd..923e6fde263e3e62da76aed366fab01b048abf69 100644 (file)
@@ -10,20 +10,21 @@ class RoachesScene(Scene):
 
     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)