""" Roach management scene. """
from pgzero.constants import keys
+from ..actors.buttons import TextButton
from .base import Scene, ChangeSceneEvent
""" 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: