Pymunx: Difference between revisions
Jump to navigation
Jump to search
Crazy-chris (talk | contribs) mNo edit summary |
Crazy-chris (talk | contribs) mNo edit summary |
||
Line 16: | Line 16: | ||
== Sources == |
== Sources == |
||
''API class with documentation'' |
''API class with documentation'' |
||
* [http://www.linuxuser.at/pymunx/pymunx.py pymunx.py] (the api class |
* [http://www.linuxuser.at/pymunx/pymunx.py pymunx.py] ''(the api class)'' |
||
''Examples'' |
''Examples'' |
||
* [http://linuxuser.at/pymunx/pymunx_demo1_ballsnsquares.py |
* [http://linuxuser.at/pymunx/pymunx_demo1_ballsnsquares.py demo1_ballsnsquares.py] ''(most simple :)'' |
||
* [http://linuxuser.at/pymunx/pymunx_demo2_drawwalls.py |
* [http://linuxuser.at/pymunx/pymunx_demo2_drawwalls.py demo2_drawwalls.py] ''(create new walls)'' |
||
* [http://linuxuser.at/pymunx/pymunx_demo3_addmany.py |
* [http://linuxuser.at/pymunx/pymunx_demo3_addmany.py demo3_addmany.py] ''(add more objects at once)'' |
||
* [http://linuxuser.at/pymunx/pymunx_demo4_drawpoly.py |
* [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 :)'' |
|||
Line 28: | Line 31: | ||
You can get the latest pymunx api class and examples bundled with the chipmunk libraries and pymunk via svn (examples/): |
You can get the latest pymunx api class and examples bundled with the chipmunk libraries and pymunk via svn (examples/): |
||
svn checkout http://pymunk.googlecode.com/svn/trunk/ pymunk-read-only |
svn checkout http://pymunk.googlecode.com/svn/trunk/ pymunk-read-only |
||
== Limitations == |
|||
Things, pymunk can handle, but the pymunx api not: |
|||
* Joints |
|||
* Non-convex Polygons |
|||
* Grouped Elements |
|||
(As a workaround, you can anyway access the whole space, which is stored in pymunx.space) |
|||
Revision as of 00:51, 10 March 2008
About
pymunx is an API for easily integrating physics into python (and pygame), using the chipmunk physics engine with the pymunk bindings. (See Python Physics for more infos.)
Status
The status is early and experimental, but already testable. Many functions of pymunk are not yet implemented, I'm quite 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 forum shared with pymunk and chipmunk.
Documentation
Sources
API class with documentation
- pymunx.py (the api class)
Examples
- demo1_ballsnsquares.py (most simple :)
- demo2_drawwalls.py (create new walls)
- demo3_addmany.py (add more objects at once)
- demo4_drawpoly.py (draw a polygon)
- demo5_draw.py (tryout for segments (buggy))
- demo6_throw_and_settings.py (++) (adjust elasticity, density, size and throw in objects)
- demo7_elasticbox.py (++) (elastic walls all around. very funny :)
Download
You can get the latest pymunx api class and examples bundled with the chipmunk libraries and pymunk via svn (examples/):
svn checkout http://pymunk.googlecode.com/svn/trunk/ pymunk-read-only
Limitations
Things, pymunk can handle, but the pymunx api not:
- Joints
- Non-convex Polygons
- Grouped Elements
(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)