Skip to main content

Load shapes from Tiled maps as pymunk objects.

Project description

PyMunkTMX
=========

What follows is a brief explanation of the project. Please see the
docs at [pymunktmx.readthedocs.org](http://pymunktmx.readthedocs.org)
for more complete information. Alternatively, you can clone and build
the docs locally by using one of the build scripts in the docs
directory.

PyMunkTMX is an extension library for PyTMX that allows you to draw
pymunk shapes in Tiled object layers and easily load them into your
game.

The main, and most useful function from PyMunkTMX is
__pymunktmx.load_shapes__. Use __load_shapes__ to populate a pymunk.Space
instance with properly configured objects from a TMX map.

### Installation ###

PyMunkTMX is registered on pypi and can be installed with
pip. Alternatively you can clone this repository. Just be sure to add
PyMunkTMX to your PYTHONPATH.

### Dependencies ###

* [pytmx](https://github.com/bitcraft/pytmx) Is required. It can be
found on pypi and installed with pip or cloned from github.
* [pymunk](https://github.com/viblo/pymunk) Is required. It can be
found on pypi and installed with pip or cloned from github.

### Generic Example ###

```python
from pytmx.tmxloader import load_tmx
from pymunk import Space
from pymunktmx import load_shapes

# Load the map data with pytmx
tiled_map = load_tmx("some/path/to/the/map.tmx")

# Create a pymunk Space instance
my_space = Space()

# Read all of the shapes from the tiled_map into the Space instance
load_shapes(tiled_map, space=my_space)
```

### PyGame Example ###

```python
import pygame
from pytmx.tmxloader import load_pygame
from pymunk import Space
from pymunk.pygame_util import draw
from pymunktmx import load_shapes

# initialize pygame
pygame.init()
screen = pygame.set_mode((640, 480))

# Load the map data with pytmx (note that pygame's display must be
# loaded before calling load_pygame)
tiled_map = load_pygame("some/path/to/the/map.tmx")

# Create a pymunk Space instance
my_space = Space()

# Read all of the shapes from the tiled_map into the Space instance
load_shapes(tiled_map, space=my_space)

# Draw all of the shapes to the pygame display surface and show them
draw(screen, my_space)
pygame.display.flip()

# Loop until smoke
while pygame.QUIT not in [e.type for e in pygame.event.get()]:
pass
```

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

PyMunkTMX-0.5.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Supported by

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