pymunk.pyglet_util
Module¶
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).
-
class
pymunk.pyglet_util.
DrawOptions
(**kwargs)[source]¶ Bases:
pymunk.space_debug_draw_options.SpaceDebugDrawOptions
-
DRAW_COLLISION_POINTS
¶ alias of
CP_SPACE_DEBUG_DRAW_COLLISION_POINTS
-
DRAW_CONSTRAINTS
¶ alias of
CP_SPACE_DEBUG_DRAW_CONSTRAINTS
-
DRAW_SHAPES
¶ alias of
CP_SPACE_DEBUG_DRAW_SHAPES
-
__init__
(**kwargs)[source]¶ Draw a pymunk.Space.
Typical usage:
>>> import pymunk >>> import pymunk.pygame_util >>> s = pymunk.Space() >>> options = pymunk.pyglet_util.DrawOptions() >>> s.debug_draw(options)
You can control the color of a Shape by setting shape.color to the color you want it drawn in.
>>> c = pymunk.Circle(None, 10) >>> c.color = (255, 0, 0, 255) # will draw my_shape in red
You can optionally pass in a batch to use for drawing. Just remember that you need to call draw yourself.
>>> my_batch = pyglet.graphics.Batch() >>> s = pymunk.Space() >>> options = pymunk.pyglet_util.DrawOptions(batch=my_batch) >>> s.debug_draw(options) >>> my_batch.draw()
See pyglet_util.demo.py for a full example
Param: - kwargs : You can optionally pass in a pyglet.graphics.Batch
If a batch is given all drawing will use this batch to draw on. If no batch is given a a new batch will be used for the drawing. Remember that if you pass in your own batch you need to call draw on it yourself.
-
collision_point_color
¶
-
color_for_shape
(shape)¶
-
constraint_color
¶
-
flags
¶
-
shape_dynamic_color
= SpaceDebugColor(r=52, g=152, b=219, a=255)¶
-
shape_kinematic_color
= SpaceDebugColor(r=39, g=174, b=96, a=255)¶
-
shape_outline_color
¶
-
shape_sleeping_color
= SpaceDebugColor(r=114, g=148, b=168, a=255)¶
-
shape_static_color
= SpaceDebugColor(r=149, g=165, b=166, a=255)¶
-