### Navigation

- index
- modules |
- next |
- previous |
- pymunk 4.0.0 documentation »
- API Reference »

# `pymunk.pygame_util` Module

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`(surface, *objs)

  Draw one or many pymunk objects on a pygame.Surface object.

  This method currently supports drawing of
    - pymunk.Space
    - pymunk.Segment
    - pymunk.Circle
    - pymunk.Poly
    - pymunk.Constraint objects

  If a Space is passed in all shapes in that space will be drawn. Unrecognized objects will be ignored (for example if you pass in a constraint).

  Typical usage:

      >>> pymunk.pygame_util.draw(screen, my_space)

  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"]

  If you do not want a shape to be drawn, set shape.ignore_draw to True.

      >>> my_shape.ignore_draw = True

  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 objects will be drawn on objs : One or many objects to draw Can be either a single object or a list like container with objects.

`pymunk.pygame_util.``get_mouse_pos`(surface)

  Get position of the mouse pointer in pymunk coordinates.

`pymunk.pygame_util.``to_pygame`(p, surface)

  Convenience method to convert pymunk coordinates to pygame surface local coordinates

`pymunk.pygame_util.``from_pygame`(p, surface)

  Convenience method to convert pygame surface local coordinates to pymunk coordinates

### Navigation

- index
- modules |
- next |
- previous |
- pymunk 4.0.0 documentation »
- API Reference »