+ class MapWidget(urwid.Text):
+ """Stores/updates/draws game map."""
+ terrain_map = ' ' * 25
+ position = [0,0]
+
+ def draw_map(self):
+ """Draw map view from .terrain_map, .position."""
+ whole_map = []
+ for c in self.terrain_map:
+ whole_map += [c]
+ pos_i = self.position[0] * (5 + 1) + self.position[1]
+ whole_map[pos_i] = '@'
+ self.set_text(''.join(whole_map))
+
+ def update_terrain(self, terrain_map):
+ """Update self.terrain_map."""
+ self.terrain_map = terrain_map
+ self.draw_map()
+
+ def update_position_y(self, position_y_string):
+ """Update self.position[0]."""
+ self.position[0] = int(position_y_string)
+ self.draw_map()
+
+ def update_position_x(self, position_x_string):
+ """Update self.position[1]."""
+ self.position[1] = int(position_x_string)
+ self.draw_map()
+