def _load_map_(self): map_name, map_data = load_json_map(self._room_) # Get objects and replace by empty tile y = 0 for row in map_data: x = 0 for src_tile in row: if src_tile in AVAILABLE_OBJECT_IDS: self._map_objects_.append((src_tile, (x * TILE_SIZE, y * TILE_SIZE))) src_tile = EMPTY_TILE if src_tile == NULL_TILE: src_tile = EMPTY_TILE map_data[y][x] = src_tile x += 1 y += 1 # Convert tiles to cells self.send_event(('load_room', map_name, map_data))
def __init__(self, level): self.event_handler = self.__discard_event__ self.roomName, self.author, roomData = load_json_map(level) self.objects = [] self.roomData = [] y = 0 for row in roomData: x = 0 filteredRow = [] for tile in row: if (tile in AVAILABLE_OBJECT_IDS): filteredRow.append(EMPTY_TILE) self.objects.append((str(uuid.uuid4()), tile, (x, y))) elif (tile == NULL_TILE): filteredRow.append(EMPTY_TILE) else: filteredRow.append(tile) x += 1 y += 1 self.roomData.append(filteredRow)