This submodule contains helper functions to help with quick prototyping
using pymunk together with pygame.
Intended to help with debugging and prototyping, not for actual production use
in a full application. The methods contained in this module is opinionated
about your coordinate system and not in any way optimized.
-
pymunk.pygame_util.draw_space(surface, space)[source]
Draw the contents of a pymunk.Space object on a pygame.Surface object
- This method currently supports drawing of
- pymunk.Segment
- pymunk.Circle
- pymunk.Poly
- pymunk.Constraint objects
You can control the color of a shape by setting shape.color to the color
you want it drawn in.
>>> my_shape.color = pygame.color.THECOLORS["pink"]
Not all constraints are currently drawn in a very clear way, but all the
different shapes should look fine both as static and dynamic objects.
See pygame_util.demo.py for a full example
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- space : pymunk.Space
The contents of this Space will be drawn on the surface.
|
-
pymunk.pygame_util.draw_shape(surface, shape)[source]
Draw a pymunk.Shape object
See the documentation of draw_space for full details
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- shape : pymunk.Shape
The Shape object to draw
|
-
pymunk.pygame_util.draw_circle(surface, circle)[source]
Draw a pymunk.Circle object
See help of draw_space for full details
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- shape : pymunk.Circle
The circle shape to draw
|
-
pymunk.pygame_util.draw_poly(surface, poly)[source]
Draw a pymunk.Poly object
See help of draw_space for full details
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- shape : pymunk.Poly
The poly shape to draw
|
-
pymunk.pygame_util.draw_segment(surface, segment)[source]
Draw a pymunk.Segment object
See help of draw_space for full details
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- shape : pymunk.Segment
The segment shape to draw
|
-
pymunk.pygame_util.draw_constraint(surface, constraint)[source]
Draw a pymunk.Constraint object
See the documentation of draw_space for full details
Parameters : |
- surface : pygame.Surface
Surface that the space will be drawn on
- shape : pymunk.Shape
The Shape object to draw
|
-
pymunk.pygame_util.to_pygame(p, surface)[source]
Convenience method to convert pymunk coordinates to pygame surface
local coordinates
-
pymunk.pygame_util.from_pygame(p, surface)[source]
Convenience method to convert pygame surface local coordinates to
pymunk coordinates