from ..gamelib.door import Door
from ..gamelib.keypad import Keypad
from ..gamelib.friendlyroach import get_friendly_roach
+from ..gamelib.items import get_item
-
TILES = {
- "cwall": Wall, # rename this everywhere
+ "cwall": Wall, # rename this everywhere
"floor": Floor,
"tunnel": Tunnel,
"underground": Underground,
}
+
class LevelLoader(ResourceLoader):
""" Level loader. """
self._level.exit = level_data["exit"]
self._level.enemies = []
self._level.friends = []
+ self._level.items = []
# Consistency check, so we can assume things are correct
# in the level renderer
for row, row_data in enumerate(self._level.tiles):
for pos in level_data['friendly roaches']:
roach = get_friendly_roach(pos[0], pos[1])
self._level.friends.append(roach)
+ for item in level_data['items']:
+ self._level.items.append(get_item(item))
return self._level
def _load_tile_images(self):
neighborhood = self._level.get_neighbors(x, y)
for layer in ['floor', 'tunnels']:
neighbors = [x[layer] if x else None for x in neighborhood]
- tile['%s image' % layer] = \
- TILES[tile[layer]['base']].image(neighbors)
+ tile['%s image' % layer] = (
+ TILES[tile[layer]['base']].image(neighbors))
# Hack this for now
if self._level.is_exit(x, y):
tile['floor image'] = Exit.image(neighbors)