Let the roaches be displayed.
authorSimon Cross <hodgestar@gmail.com>
Wed, 2 Mar 2016 15:41:42 +0000 (17:41 +0200)
committerSimon Cross <hodgestar@gmail.com>
Wed, 2 Mar 2016 15:41:42 +0000 (17:41 +0200)
koperkapel/scenes/roaches.py

index 429ec8f44bbc4ed85eafac31be5579012bc1b7e5..aab4a9a2be480a310f5e820a8abf2beb77f705bd 100644 (file)
@@ -1,6 +1,7 @@
 """ Roach management scene. """
 
 from pgzero.constants import keys
+from ..actors.buttons import TextButton
 from .base import Scene, ChangeSceneEvent
 
 
@@ -8,10 +9,23 @@ class RoachesScene(Scene):
     """ Roach management scene. """
 
     def __init__(self):
-        pass
+        super().__init__()
+        self._roach_actors = {}
 
-    def draw(self, screen, viewport):
-        screen.clear()
+    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"]]
+            else:
+                actor = TextButton("%s [%s]" % (
+                    roach["name"],
+                    ", ".join("%s=%s" % kv for kv in sorted(
+                        roach["attributes"].items()),
+                    )))
+                self._roach_actors[roach["name"]] = actor
+                self.actors.add(actor)
+            # TODO: remove missing roaches
+            actor.pos = (300, 100 + i * 100)
 
     def on_key_down(self, key, mod, unicode):
         if key == keys.ESCAPE: