Pymunx/Documentation: Difference between revisions
< Pymunx
Jump to navigation
Jump to search
Crazy-chris (talk | contribs) No edit summary |
Crazy-chris (talk | contribs) m (+get_element_count) |
||
Line 1: | Line 1: | ||
__NOTOC__ |
__NOTOC__ |
||
== pymunx == |
|||
: ''Physics API for easy usage of chipmunk physics engine in pygame (with pymunk)'' |
: ''Physics API for easy usage of chipmunk physics engine in pygame (with pymunk)'' |
||
<table border="0"> |
<table border="0"> |
||
<tr><td style="padding-left:80px;">[[#pymunx. |
<tr><td style="padding-left:80px;">[[#pymunx.__init___|pymunx.__init__]]</td> |
||
<td style="padding-left:20px;">Init function: pymunk, get flags, get screen size, init space</td></tr> |
<td style="padding-left:20px;">Init function: pymunk, get flags, get screen size, init space</td></tr> |
||
Line 40: | Line 41: | ||
<tr><td style="padding-left:80px;">[[#pymunx.add_poly|pymunx.add_poly]]</td> |
<tr><td style="padding-left:80px;">[[#pymunx.add_poly|pymunx.add_poly]]</td> |
||
<td style="padding-left:20px;">Add a polygon</td></tr> |
<td style="padding-left:20px;">Add a polygon</td></tr> |
||
<tr><td style="padding-left:80px;">[[#pymunx.get_element_count|pymunx.get_element_count]]</td> |
|||
<td style="padding-left:20px;">Returns the current element count</td></tr> |
|||
</table> |
</table> |
||
Line 65: | Line 69: | ||
=== pymunx.vec2df === |
=== pymunx.vec2df === |
||
:<big>vec2df(self, pos)</big> |
:<big>pymunx.vec2df(self, pos)</big> |
||
::* Convert a pygame pos to a vec2d with flipped y coordinate |
::* Convert a pygame pos to a vec2d with flipped y coordinate |
||
::* Parameters: pos = (int(x), int(y))</big> |
::* Parameters: pos = (int(x), int(y))</big> |
||
Line 72: | Line 76: | ||
=== pymunx.autoset_screen_size === |
=== pymunx.autoset_screen_size === |
||
:<big>autoset_screen_size (self) |
:<big>pymunx.autoset_screen_size (self) |
||
::* Get screensize from pygame. Call this only on resize |
::* Get screensize from pygame. Call this only on resize |
||
::* Returns: - |
::* Returns: - |
||
Line 78: | Line 82: | ||
=== pymunx.get_pymunk_flags === |
=== pymunx.get_pymunk_flags === |
||
:<big>get_pymunk_flags (self)</big> |
:<big>pymunx.get_pymunk_flags (self)</big> |
||
::* Check pymunk version, adjusts settings and returns new flagset |
::* Check pymunk version, adjusts settings and returns new flagset |
||
::* Returns: class pymunk_flags |
::* Returns: class pymunk_flags |
||
Line 84: | Line 88: | ||
=== pymunx.update === |
=== pymunx.update === |
||
:<big>update (self, fps=50.0, steps=5)</big> |
:<big>pymunx.update (self, fps=50.0, steps=5)</big> |
||
::* Update thy physics. fps is optional and by default set to 50.0 - steps is substeps per update |
::* Update thy physics. fps is optional and by default set to 50.0 - steps is substeps per update |
||
::* Returns: - |
::* Returns: - |
||
Line 90: | Line 94: | ||
=== pymunx.draw === |
=== pymunx.draw === |
||
:<big>draw (self, surface)</big> |
:<big>pymunx.draw (self, surface)</big> |
||
::* Iterate through all elements and call draw_shape with each |
::* Iterate through all elements and call draw_shape with each |
||
::* Parameters: surface = pygame.Surface |
::* Parameters: surface = pygame.Surface |
||
Line 97: | Line 101: | ||
=== pymunx.draw_shape === |
=== pymunx.draw_shape === |
||
:<big>draw_shape (self, surface, shape)</big> |
:<big>pymunx.draw_shape (self, surface, shape)</big> |
||
::* Draw a given shape (circle, segment, poly) on the surface |
::* Draw a given shape (circle, segment, poly) on the surface |
||
::* Parameters: surface = pygame.Surface | shape = pymunk.Shape |
::* Parameters: surface = pygame.Surface | shape = pymunk.Shape |
||
Line 104: | Line 108: | ||
=== pymunx.add_wall === |
=== pymunx.add_wall === |
||
:<big>add_wall (self, p1, p2, friction=10.0)</big> |
:<big>pymunx.add_wall (self, p1, p2, friction=10.0)</big> |
||
::* Add a fixed wall between points p1 and p2. friction is a optional parameter |
::* Add a fixed wall between points p1 and p2. friction is a optional parameter |
||
::* Parameters: p = (int(x), int(y))</big> |
::* Parameters: p = (int(x), int(y))</big> |
||
Line 111: | Line 115: | ||
=== pymunx.add_ball === |
=== pymunx.add_ball === |
||
:<big>add_ball (self, pos, radius=15, mass=10.0, inertia=1000, friction=0.5)</big> |
:<big>pymunx.add_ball (self, pos, radius=15, mass=10.0, inertia=1000, friction=0.5)</big> |
||
::* Add a ball at pos. Other parameters are optional |
::* Add a ball at pos. Other parameters are optional |
||
::* Parameters: pos = (int(x), int(y))</big> |
::* Parameters: pos = (int(x), int(y))</big> |
||
Line 118: | Line 122: | ||
=== pymunx.add_square === |
=== pymunx.add_square === |
||
:<big>add_square (self, pos, a=18, mass=5.0, friction=0.2)</big> |
:<big>pymunx.add_square (self, pos, a=18, mass=5.0, friction=0.2)</big> |
||
::* Add a square at pos. |
::* Add a square at pos. |
||
::* Parameters: pos = (int(x), int(y))</big> |
::* Parameters: pos = (int(x), int(y))</big> |
||
Line 125: | Line 129: | ||
=== pymunx.add_poly === |
=== pymunx.add_poly === |
||
:<big>add_poly(self, points, mass=150.0, friction=10.0)</big> |
:<big>pymunx.add_poly(self, points, mass=150.0, friction=10.0)</big> |
||
::* Add a polygon from given a given pygame pointlist |
::* Add a polygon from given a given pygame pointlist |
||
::* Parameters: points = [(int(x), int(y)), (int(x), int(y)), ...] |
::* Parameters: points = [(int(x), int(y)), (int(x), int(y)), ...] |
||
::* Returns: - |
::* Returns: - |
||
=== pymunx.get_element_count === |
|||
:<big>pymunx.get_element_count(self)</big> |
|||
::* Returns the current element count |
|||
::* Returns: int(n) |
Revision as of 20:15, 8 March 2008
pymunx
- Physics API for easy usage of chipmunk physics engine in pygame (with pymunk)
pymunx.__init__ | Init function: pymunk, get flags, get screen size, init space |
pymunx.set_info | Set the Info-Text for the upper left corner |
pymunx.flipy | Convert Chipmunk y-coordinate to pyGame |
pymunx.vec2df | Convert a pygame pos to a vec2d with flipped y coordinate |
pymunx.autoset_screen_size | Get screensize from pygame |
pymunx.get_pymunk_flags | Check pymunk version and adjusts settings |
pymunx.update | Update the physics space |
pymunx.draw | Call draw_shape for each element |
pymunx.draw_shape | Draw a given shape (circle, segment, poly) on the surface |
pymunx.add_wall | Add a fixed wall |
pymunx.add_ball | Add a ball |
pymunx.add_square | Add a square |
pymunx.add_poly | Add a polygon |
pymunx.get_element_count | Returns the current element count |
pymunx.__init__
- def __init__(self, gravity=(0.0,-900.0))
- Init function - pymunk, get flags, get screen size, init space
- Parameters: gravity = (int(x), int(y))
- Returns: class pymunx
pymunx.set_info
- pymunx.set_info(self, txt)
- Set the Info-Text which will be blit at the upper left corner each update
- Parameters: txt = str (break lines with \n)
- Returns: -
pymunx.flipy
- pymunx.flipy (self, y)
- Convert Chipmunk y-coordinate to pyGame (y = -y + self.display_height)
- Parameters: y = int
- Returns: int(y_new)
pymunx.vec2df
- pymunx.vec2df(self, pos)
- Convert a pygame pos to a vec2d with flipped y coordinate
- Parameters: pos = (int(x), int(y))
- Returns: class vec2d((pos[0], self.flipy(pos[1])))
pymunx.autoset_screen_size
- pymunx.autoset_screen_size (self)
- Get screensize from pygame. Call this only on resize
- Returns: -
pymunx.get_pymunk_flags
- pymunx.get_pymunk_flags (self)
- Check pymunk version, adjusts settings and returns new flagset
- Returns: class pymunk_flags
pymunx.update
- pymunx.update (self, fps=50.0, steps=5)
- Update thy physics. fps is optional and by default set to 50.0 - steps is substeps per update
- Returns: -
pymunx.draw
- pymunx.draw (self, surface)
- Iterate through all elements and call draw_shape with each
- Parameters: surface = pygame.Surface
- Returns: -
pymunx.draw_shape
- pymunx.draw_shape (self, surface, shape)
- Draw a given shape (circle, segment, poly) on the surface
- Parameters: surface = pygame.Surface | shape = pymunk.Shape
- Returns: -
pymunx.add_wall
- pymunx.add_wall (self, p1, p2, friction=10.0)
- Add a fixed wall between points p1 and p2. friction is a optional parameter
- Parameters: p = (int(x), int(y))
- Returns: -
pymunx.add_ball
- pymunx.add_ball (self, pos, radius=15, mass=10.0, inertia=1000, friction=0.5)
- Add a ball at pos. Other parameters are optional
- Parameters: pos = (int(x), int(y))
- Returns: -
pymunx.add_square
- pymunx.add_square (self, pos, a=18, mass=5.0, friction=0.2)
- Add a square at pos.
- Parameters: pos = (int(x), int(y))
- Returns: -
pymunx.add_poly
- pymunx.add_poly(self, points, mass=150.0, friction=10.0)
- Add a polygon from given a given pygame pointlist
- Parameters: points = [(int(x), int(y)), (int(x), int(y)), ...]
- Returns: -
pymunx.get_element_count
- pymunx.get_element_count(self)
- Returns the current element count
- Returns: int(n)