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.2.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file PyMunkTMX-0.5.2.tar.gz.

File metadata

  • Download URL: PyMunkTMX-0.5.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyMunkTMX-0.5.2.tar.gz
Algorithm Hash digest
SHA256 56f094945aa552f17fd3410277e2f3a78ab6df50bc36a1915027c5cbbe6c31e4
MD5 a7c9a85611bcb7a5f80dce51442ebf44
BLAKE2b-256 0c41043752dd8ba9090841b88d3e764998b82fadbd251cd4eb064051d2226249

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