Add a list of actors to scenes.
authorSimon Cross <hodgestar@gmail.com>
Sun, 28 Feb 2016 20:24:49 +0000 (22:24 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 28 Feb 2016 20:24:49 +0000 (22:24 +0200)
koperkapel/scenes/base.py

index 9bad13cd9f03b9e1d172c9c977ae575002a51c88..b6d6ff9bf86262a89345e0de38f8c0fadb162286 100644 (file)
@@ -77,9 +77,31 @@ class ChangeSceneEvent(Event):
     ENGINE_METHOD = "change_scene"
 
 
+class Actors:
+    """ A list of actors. """
+
+    def __init__(self):
+        self._actors = []
+
+    def add(self, actor):
+        self._actors.append(actor)
+        return actor
+
+    def remove(self, actor):
+        self._actors.remove(actor)
+        return actor
+
+    def draw(self, screen):
+        for actor in self._actors:
+            actor.draw()  # TODO: allow an option screen to be passed in
+
+
 class Scene:
     """ Base class for scenes. """
 
+    def __init__(self):
+        self.actors = Actors()
+
     def enter(self):
         pass
 
@@ -90,7 +112,8 @@ class Scene:
         pass
 
     def draw(self, screen):
-        pass
+        screen.clear()
+        self.actors.draw(screen)
 
     def on_mouse_down(self, pos, button):
         pass