Pymunx: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (+info)
m (Redirecting to Elements)
 
Line 1: Line 1:
#REDIRECT [[Elements]]
<div style="float:left;padding-right:20px;">__TOC__</div>
== About ==
<div><div style="float:left;width:100px;">[[Image:Pymunx_80px.png]]</div>
''pymunx'' is an API for easily integrating physics into python (and [[pygame]]), using the [http://wiki.slembcke.net/main/published/Chipmunk chipmunk] physics engine with the [http://code.google.com/p/pymunk/ pymunk] bindings. (See [[Python Physics]] for more infos.)</div>



== Status ==
The status is early and experimental, but already testable. Only few functions of pymunk are not yet implemented, and the whole chipmunk commandset is available via pymunx.space. I'm quite working on it and will post updates frequently the next time, so check back often :) I'll post my updates and demos here, on http://www.linuxuser.at/pymunx, and there's also a [http://www.slembcke.net/forums/viewforum.php?f=6 forum] shared with pymunk and chipmunk.


== Features ==
Fast, Easy to use, Circles, Squares, Segments, Polygons, Colissions, Variable Gravity, Density, Mass, Friction, Elasticity, Inertia, Impulses, Screenshots, Screencasts, Cross-Platform, Entertaining, Fascinating, ...


== Documentation ==
* <big>[[Pymunx/Documentation]]</big>
* [http://www.linuxuser.at/pymunx/pymunk_api Pymunk], [http://files.slembcke.net/chipmunk/chipmunk-docs.html Chipmunk]


== Sources ==
* [[Image:Pymunx.zip]] ''(all you need to get started :) (115 kb)''


''API class with documentation''
* [http://www.linuxuser.at/pymunx/pymunx.py pymunx.py] ''(the api class)''

''Examples''
* [http://linuxuser.at/pymunx/pymunx_demo1_ballsnsquares.py demo1_ballsnsquares.py] ''(most simple :)''
* [http://linuxuser.at/pymunx/pymunx_demo2_drawwalls.py demo2_drawwalls.py] ''(create new walls)''
* [http://linuxuser.at/pymunx/pymunx_demo3_addmany.py demo3_addmany.py] ''(add more objects at once)''
* [http://linuxuser.at/pymunx/pymunx_demo4_drawpoly.py demo4_drawpoly.py] ''(draw a polygon)''
* [http://www.linuxuser.at/pymunx/pymunx_demo5_draw.py demo5_draw.py] ''(tryout for segments (buggy))''
* [http://www.linuxuser.at/pymunx/pymunx_demo6_throw_and_settings.py demo6_throw_and_settings.py] ''(++) (adjust elasticity, density, size and throw in objects)''
* [http://www.linuxuser.at/pymunx/pymunx_demo7_elasticbox.py demo7_elasticbox.py] ''(++) (elastic walls all around. very funny :)''
* [http://www.linuxuser.at/pymunx/pymunx_demo8_gravityfun.py demo8_gravityfun.py] ''(+++) (change the gravity vector (or set to (0,0) by right mouse click)''


== Download ==
You can either take the latest zip ([[Image:Pymunx.zip]]), or get the pymunx api class and examples bundled with the chipmunk libraries and pymunk via svn:
svn checkout http://pymunk.googlecode.com/svn/trunk/ pymunk-read-only


== Limitations ==
* Screencast works only in Linux with mencoder installed

Things, pymunx can't handle yet:
* Joints
* Grouped Elements
* maybe more :)

(As a workaround, you can anyway access the whole space, which is stored in pymunx.space)


== pyGame Example ==
The typical usage in pygame looks like this:

import pygame
from pygame.locals import *
from pygame.color import *
from pymunx import *
pygame.init()
screen = pygame.display.set_mode((800, 800))
clock = pygame.time.Clock()
world = pymunx()
world.add_wall((100, 200), (300, 200))
# Main Game Loop:
while running:
# Event Handling
# Maybe calling world.add_ball(event.pos) or world.add_square(event.pos)
# ...
screen.fill((255,255,255))
# Update & Draw World
world.update()
world.draw(screen)
# Flip Display
pygame.display.flip()
# Try to stay at 50 FPS
clock.tick(50)


== Screenshots ==
''' [http://linuxuser.at/pymunx/pymunx_demo4_drawpoly.py pymunx_demo4_drawpoly.py] '''

[[Image:Screenshot1.png|400px]] [[Image:Screenshot2.png|400px]]

[[Image:Screenshot3.png|400px]] [[Image:Screenshot4.png|400px]]

Latest revision as of 18:47, 12 March 2008

Redirect to: