Elma Python Library is a python library for manipulating Elasto Mania files. Currently, it supports simple level, replay, LGR and state.dat manipulation and level rendering.
Documentation is available at elma-python-library.readthedocs.org.
pip install elma
from elma import Level, Obj, Picture, Point, Polygon
level = Level()
level.name = 'My first level'
level.polygons = [
Polygon([Point(-10, -10),
Point(10, -10),
Point(10, 10),
Point(-10, 10)]),
]
level.objects = [
Obj(Point(0, 0), Obj.START),
Obj(Point(0, 10), Obj.FOOD, gravity=Obj.GRAVITY_UP),
Obj(Point(0, 0), Obj.FLOWER),
]
level.pictures = [
Picture(Point(2, 8), picture_name='flag'),
]
The above snippet defines a simple level that looks like this:
from elma import Level
level = Level.load('mylevel.lev')
level.save('mylevel.lev')
from elma import Level
level1 = Level.load('mylevel1.lev')
level2 = Level.load('mylevel2.lev')
if level1 == level2:
level1.top10.merge(level2.top10)
level1.save('mylevel.lev')
from elma import Replay
replay = Replay.load('myreplay.rec')
replay.save('myreplay.rec')
from elma import State
state = State.load('state.dat')
print(state) # prints the players and their total times
with open('stats.txt', 'w') as f:
f.write(state.stats_txt())
virtualenv venv
. venv/bin/activate
make setup
make test
To lint the project, do:
make lint
To run static type checking with mypy, do:
make mypy
Pull requests welcome!