This submodule contains helper functions to help with quick prototyping using pymunk together with pyglet.
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 very optimized (they use batched drawing, but there is probably room for optimizations still).
Draw one or many pymunk objects. It is perfectly fine to pass in a whole Space object.
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.pyglet_util.draw(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 = (255, 0, 0) # will draw my_shape in red
If you do not want a shape to be drawn, set shape.ignore_draw to True.
>>> my_shape.ignore_draw = True
(However, if you want to ignore most shapes its probably more performant to only pass in those shapes that you want to be drawn to the draw method)
You can optionally pass in a batch to use. Just remember that you need to call draw yourself.
>>> pymunk.pyglet_util.draw(my_shape, batch = my_batch)
>>> my_batch.draw()
See pyglet_util.demo.py for a full example
Param : |
|
---|