Mercurial > pyntnclick
comparison gamelib/state.py @ 32:18cb1af411ef
Add helper for adding items. Give items names. Make things take a rectangle.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sun, 22 Aug 2010 19:38:32 +0200 |
parents | daf9eecb670f |
children | f8e02d02c782 |
comparison
equal
deleted
inserted
replaced
31:dc7f94742aab | 32:18cb1af411ef |
---|---|
31 # current scene | 31 # current scene |
32 self.current_scene = None | 32 self.current_scene = None |
33 | 33 |
34 def add_scene(self, scene): | 34 def add_scene(self, scene): |
35 self.scenes[scene.name] = scene | 35 self.scenes[scene.name] = scene |
36 | |
37 def add_item(self, item): | |
38 self.scenes[item.name] = item | |
36 | 39 |
37 def load_scenes(self, modname): | 40 def load_scenes(self, modname): |
38 mod = __import__("gamelib.scenes.%s" % (modname,), fromlist=[modname]) | 41 mod = __import__("gamelib.scenes.%s" % (modname,), fromlist=[modname]) |
39 for scene_cls in mod.SCENES: | 42 for scene_cls in mod.SCENES: |
40 self.add_scene(scene_cls(self)) | 43 self.add_scene(scene_cls(self)) |
86 | 89 |
87 | 90 |
88 class Thing(object): | 91 class Thing(object): |
89 """Base class for things in a scene that you can interact with.""" | 92 """Base class for things in a scene that you can interact with.""" |
90 | 93 |
91 def __init__(self): | 94 def __init__(self, rect): |
92 pass | 95 self.rect = rect |
96 # TODO: add masks | |
97 # TODO: add images | |
93 | 98 |
94 def interact(self, item): | 99 def interact(self, item): |
95 pass | 100 pass |
96 | 101 |
97 def draw(self, surface): | 102 def draw(self, surface): |
99 | 104 |
100 | 105 |
101 class Item(object): | 106 class Item(object): |
102 """Base class for inventory items.""" | 107 """Base class for inventory items.""" |
103 | 108 |
109 # name of item | |
110 NAME = None | |
111 | |
104 def __init__(self): | 112 def __init__(self): |
105 pass | 113 self.name = self.NAME |
106 # needs cursor | 114 # TODO: needs image |
115 # TODO: needs cursor | |
107 | 116 |