Skip to main content

pymunk is a easy-to-use pythonic 2d physics library built on top of Chipmunk

Project description

About

pymunk is a easy-to-use pythonic 2d physics library that can be used whenever you need 2d rigid body physics from Python. It is built on top of the very nice 2d physics library Chipmunk.

2007 - 2013, Victor Blomqvist - vb@viblo.se, MIT License

This release is based on the latest pymunk release (4.0.0), using chipmunk 6.2 rev 3bdf1b7b3c (source included)

Homepage:

http://www.pymunk.org

Forum:

http://chipmunk-physics.net/forum/

Email:

vb@viblo.se

Getting the latest SVN copy:

svn checkout http://pymunk.googlecode.com/svn/trunk pymunk-read-only

Chipmunk:

http://chipmunk-physics.net/

How to Use

pymunk ships with a number of demos in the examples directory, and its complete documentation including API Reference.

If chipmunk doesnt ship with a chipmunk binary your platform can understand (currently Windows and Linux 32bit and 64 bit are included) you will have to compile chipmunk before install. See section CHIPMUNK in this readme for (very simple) instructions.

To install you can either run:

> python setup.py install

or simply put the pymunk folder where your program/game can find it. (like /my_python_scripts/yourgame/pymunk). The chipmunk binary library is located in the pymunk folder.

The easy way to get started is to check out the examples/ directory, and run ‘run.py python arrows.py’ and so on, and see what each one does :)

Example

Quick code example:

import pymunk               # Import pymunk..

space = pymunk.Space()      # Create a Space which contain the simulation
space.gravity = 0,-1000     # Set its gravity

body = pymunk.Body(1,1666)  # Create a Body with mass and moment
body.position = 50,100      # Set the position of the body

poly = pymunk.Poly.create_box(body) # Create a box shape and attach to body
space.add(body, poly)       # Add both body and shape to the simulation

while True:                 # Infinite loop simulation
    space.step(0.02)        # Step the simulation one step forward

For more detailed and advanced examples, take a look at the included demos (in examples/).

Dependencies / Requirements

  • python (tested on cpython 2.6, 2.7 and 3.2, 3.3. Also on pypy 2.1)

  • chipmunk (pymunk ships with a set of chipmunk libraries)

  • pygame (optional, you need it to run most of the demos)

  • pyglet (optional, you need it to run the moon buggy demo)

  • sphinx (optional, you need it to build documentation)

  • ctypeslib & GCC_XML (optional, you need them to generate new bindings)

Chipmunk

Compiled libraries of Chipmunk compatible Windows and Linux 32bit and 64bit are distributed with pymunk. If pymunk doesnt have your particular platform included, you can compile Chipmunk by hand with a custom setup argument:

> python setup.py build_chipmunk

The compiled file goes into the /pymunk folder (same as _chipmunk.py, util.py and others). If the compile fail, please check the readme in chipmunk_src for generic instructions on how to compile with gcc, or download the relevant release from Chipmunk homepage and follow its instructions.

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

pymunk-4.0.0.zip (2.0 MB view details)

Uploaded Source

Built Distribution

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

pymunk-4.0.0.win32.exe (666.2 kB view details)

Uploaded Source

File details

Details for the file pymunk-4.0.0.zip.

File metadata

  • Download URL: pymunk-4.0.0.zip
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pymunk-4.0.0.zip
Algorithm Hash digest
SHA256 7102b1a63d4eeb9eb459d4733663bc0af4ea59f664e3fac2228c704ec6768937
MD5 0b1fe07990840661e22d128c1a696009
BLAKE2b-256 202f3cda672816ad399f901a49ecf6f3a038a06c6853e31596b40c0780c00f29

See more details on using hashes here.

File details

Details for the file pymunk-4.0.0.win32.exe.

File metadata

  • Download URL: pymunk-4.0.0.win32.exe
  • Upload date:
  • Size: 666.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pymunk-4.0.0.win32.exe
Algorithm Hash digest
SHA256 8c2ec9de3626d0b4d68bcae9759c315d19528a7c8949e3ed5ccc5465cdcaa83d
MD5 5887c75a7b691810c0b72dfc491ce7bf
BLAKE2b-256 370cbfce9daec2de0297ea5b6f5f048646c7320e1fa13789157ee4db791a8543

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