Newer
Older
with open("minigame_map.txt", "r", encoding="utf-8") as f:
visual_map = f.read().splitlines()
def find_char_in_map(char, the_map):
"""
Used for finding the index of a character in the map
"""
for y, row in enumerate(the_map):
for x, tile in enumerate(row):
if tile == char:
return x, y
game_map = [[x for x in line] for line in visual_map]
map_border_x = 2
map_border_y = 1
# Take the length of an element in the list which is the map "width" then take 1 as list indexing
# starts at zero then take off the border
game_width = len(game_map[0]) - 1 - map_border_x
# Take the length of the list which is the map "height" then take 1 as list indexing
# starts at zero then take off the border
game_height = len(game_map) - 1 - map_border_y
game_info = {"width": game_width, "height": game_height, "border_x": map_border_x, "border_y": map_border_y,
"arrow counter index": find_char_in_map("?", game_map),
"enemy counter index": find_char_in_map("!", game_map)}