Mercurial > boomslang
diff gamelib/state.py @ 39:088a101f5b94
Add an example Thing to cryo scene.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sun, 22 Aug 2010 22:07:45 +0200 |
parents | ebc76bc0c067 |
children | ad6f56bfa8b7 |
line wrap: on
line diff
--- a/gamelib/state.py Sun Aug 22 20:28:24 2010 +0200 +++ b/gamelib/state.py Sun Aug 22 22:07:45 2010 +0200 @@ -79,6 +79,9 @@ def add_item(self, item): self.state.add_item(item) + def add_thing(self, thing): + self.things[thing.name] = thing + def draw_background(self, surface): surface.blit(self._background, (0, 0), None, BLEND_ADD) @@ -94,11 +97,21 @@ class Thing(object): """Base class for things in a scene that you can interact with.""" - def __init__(self, rect): + def __init__(self, name, rect): + self.name = name + # area within scene that triggers calls to interact self.rect = rect + # these are set by set_scene + self.scene = None + self.state = None # TODO: add masks # TODO: add images + def set_scene(self, scene): + assert self.scene is None + self.scene = scene + self.state = scene.state + def interact(self, item): pass