| 129 | class Model(object): |
| 130 | |
| 131 | def __init__(self): |
| 132 | |
| 133 | # A Batch is a collection of vertex lists for batched rendering. |
| 134 | self.batch = pyglet.graphics.Batch() |
| 135 | |
| 136 | # A TextureGroup manages an OpenGL texture. |
| 137 | self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture()) |
| 138 | |
| 139 | # A mapping from position to the texture of the block at that position. |
| 140 | # This defines all the blocks that are currently in the world. |
| 141 | self.world = {} |
| 142 | |
| 143 | # Same mapping as `world` but only contains blocks that are shown. |
| 144 | self.shown = {} |
| 145 | |
| 146 | # Mapping from position to a pyglet `VertextList` for all shown blocks. |
| 147 | self._shown = {} |
| 148 | |
| 149 | # Mapping from sector to a list of positions inside that sector. |
| 150 | self.sectors = {} |
| 151 | |
| 152 | # Simple function queue implementation. The queue is populated with |
| 153 | # _show_block() and _hide_block() calls |
| 154 | self.queue = deque() |
| 155 | |
| 156 | self._initialize() |
| 157 | |
| 158 | def _initialize(self): |
| 159 | """ Initialize the world by placing all the blocks. |