Python Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
elma
tests
.gitignore
.travis.yml
LICENCE
Makefile
README.md
requirements.txt
setup.py

README.md

Elma Python Library

Travis PyPI Licence

Elma Python Library is a python library for manipulating Elastomania files. Currently, it supports simple level and replay manipulation.

Documentation

Documentation is available at elma-python-library.readthedocs.org.

Installation

pip install elma

Usage

Creating a simple level

from elma.models import Level
from elma.models import Obj
from elma.models import Picture
from elma.models import Point
from elma.models import 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:

Loading a level from file

from elma.packing import unpack

with open('mylevel.lev') as f:
    level = unpack(f.read())

Saving a level to file

from elma.packing import pack

level = ...

with open('mylevel.lev', 'w') as f:
    f.write(pack(level))

Development setup

virtualenv venv
. venv/bin/acivate
make setup

Running tests

python -m unittest
make test

Linting

To lint the project, do:

make lint

Contributing

Pull requests welcome!