def decode_tile(char):
tile = Tile()
if char == '*':
#code to create whatever tile this is
''' lots more cases here '''
elif char == '#':
#like this
tile.name = 'stone_wall'
tile.blocks = True
tile.blocks_sight = True
return tile
def load_map(filen):
map = list()
#open txt file where you store the map
with open(filen) as text:
#2d for-loop through tiles
for line in text:
#current row of tiles
current_row = list()
for tile in line:
#current column in the row
current_row.append(decode_tile(tile))
#finalize row
map.append(current_row)
return map #stores map as a 2d array of tiles