From: Simon Cross Date: Wed, 2 Mar 2016 15:41:42 +0000 (+0200) Subject: Let the roaches be displayed. X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=6760d50976921f10084d64a41a84264cc4e3694f;p=koperkapel.git Let the roaches be displayed. --- diff --git a/koperkapel/scenes/roaches.py b/koperkapel/scenes/roaches.py index 429ec8f..aab4a9a 100644 --- a/koperkapel/scenes/roaches.py +++ b/koperkapel/scenes/roaches.py @@ -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: