A simple game made as a hobby. Use the mouse to control the starship and collect the gems. The faster you collect them the better. Needs pygame (2.1.2) to run.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

35 lines
1.2 KiB

from xml.etree import ElementTree
from itertools import chain
def read_level(file_path):
schema = '{http://www.w3.org/2000/svg}'
root = ElementTree.parse(file_path).getroot()
active = next(filter(
lambda g: g.get('id') == "ACTIVE",
root.iter(f"{schema}g")))
block_pos = [ (
float(rect.get('x')),
float(rect.get('y')),
float(rect.get('width')),
float(rect.get('height')),
)
for rect in active.iter(f"{schema}rect")
]
gem_pos = []
ellipses = chain(
active.iter(f"{schema}circle"),
active.iter(f"{schema}ellipse")
)
for ellipse in ellipses:
if ellipse.get('id') == "START":
start = (
float(ellipse.get(f'cx')),
float(ellipse.get(f'cy')),
)
else:
gem_pos.append((
float(ellipse.get('cx')),
float(ellipse.get('cy')),
))
return (start, gem_pos, block_pos)