Skip to main content

A parser for I Wanna Maker maps

Project description

pywannamaker

A python package for parsing and serializing I Wanna Maker maps from and back to their XML format.

Usage

Importing the pywannamaker module imports all required submodules.

Opening maps

Several functions load and parse a map.

  • parseFile does so from a file object or file path.
  • parseLocal opens a map with the provided name in the actual game maps folder (specified in config.py).
  • parseString opens a map from the provided string.

Worth noting is that each of these functions can correctly open any non-param element, meaning you can e.g. store individual objects in files.

Saving

  • Map.serialize returns the map string.
  • Map.save saves the map to the provided file path.
  • Map.saveLocal saves the name in the game maps folder with the provided name

Object structure

  • Map
    • properties: Properties
    • objects: [Object]
  • Properties
    • name: str
    • version: str
    • tileset: str
    • tileset2: str
    • bg: str
    • spikes: str
    • spikes2: str
    • width: str
    • height: str
    • colors: str
    • scroll_mode: str
    • music: str
  • Object
    • type: int
    • x: int
    • y: int
    • sprite_angle: int
    • params: dict[str, str]
    • events: [Event]
    • children: [Object]
    • linked: [Object]
  • Event
    • event_index: int
    • params: dict[str, str]
    • events: [Event]

Examples

import pywannamaker as pywm
m = pywm.Map()
m.saveLocal('empty.map')

Creates a new map and saves it.

import pywannamaker as pywm
m = pywm.parseLocal('input.map')
for o in m.objects:
    o.x = float(m.properties.width) - o.x

Mirrors a level horizontally

from pywannamaker import Object, Event, ObjectType, EventType, ActionType
cannon = Object(ObjectType.CANNON, 400, 304)
onmetronome = Event(EventType.ONMETRONOMETICK)
onmetronome.params['frames'] = 25
onmetronome.events.append(Event(ActionType.FIRECANNON))
cannon.events.append(onmetronome)

Creates a new cannon object, and gives it an On metronome -> Fire event.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywannamaker-0.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywannamaker-0.0.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pywannamaker-0.0.3.tar.gz.

File metadata

  • Download URL: pywannamaker-0.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pywannamaker-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5605e0b5215ad18f91c33cbf0d9dc1cb6e48ddbf65909260819efb15ae2af70c
MD5 ffdb854ae7af73b044f2122faaf4a15e
BLAKE2b-256 01a0b13385bfc9efd88159a4dbd4bf5e26074992ded433cf25265252ae54fe41

See more details on using hashes here.

File details

Details for the file pywannamaker-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pywannamaker-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pywannamaker-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 803d7a6a1a4f7a0543fb589ed15acf70b3459c0fd881d8858e7ee0e1cf5ae6ff
MD5 c3cfaada88ed888f87dfe9c7130a65d9
BLAKE2b-256 af2bfa7d35d4e79ade0675e171c5bbf8ea8912bcf46fb52699f0446da5dc680d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page