示例#1
0
 def generateOreSurfs(self):
   ore_image = media.get("ore.png")
   for name in self.ores_dict:
     new_ore = ore_image.copy()
     new_ore.fill(getRandomColor(), None, pygame.BLEND_RGBA_MULT)
     self.ores_dict[name]['image'] = new_ore
示例#2
0
for row in table.find_all("tr")[1:]:
  dataset = []
  for td in row.find_all("td"):
    dataset.append(td.get_text())
  datasets.append(dataset)

# Convert list into yaml file and only take the parts that are useful
yaml_dict = {}

for element in datasets:
  y_dict = {}
  y_dict['z'] = int(str(element[1]).replace(',', ''))
  if element[5] == '':
    element[5] = 0
  y_dict['amount'] = float(str(element[5]).replace(',', ''))
  y_dict['color'] = getRandomColor()
  yaml_dict[str(element[2])] = y_dict


# Function for the below sorting
def sort_by_z(key):
  return yaml_dict[key]['z']

# Sort keys of yaml_dict into z_sorted by yaml_dict[key]['z']
z_sorted = sorted(yaml_dict, key=sort_by_z, reverse=False)

# Convert Z to game-usable z levels
last_z = yaml_dict[z_sorted[0]]['z']
level = 10
for key in z_sorted:
  z = yaml_dict[key]['z']