screen.blit(actor._surf, actor.topleft)
+def defer_to_update(f):
+ """ Defers a function until the next update run. """
+ @functools.wraps(f)
+ def wrapper(self, *args, **kw):
+ self._deferred_updates.append((f, args, kw))
+ return wrapper
+
+
class Scene:
""" Base class for scenes. """
def __init__(self):
self.actors = Actors()
self.viewport = (0, 0)
+ self._deferred_updates = []
def move_screen(self, offset):
self.viewport = (self.viewport[0] + offset[0],
pass
def update(self, world, engine, dt):
- pass
+ deferred_updates, self._deferred_updates = self._deferred_updates, []
+ for f, args, kw in deferred_updates:
+ f(self, world, *args, **kw)
def draw(self, screen):
screen.clear()