0

How do I visualize or show the shape of a pymunk body in pygame? This is what I have tried so far.

import pygame, pymunk
from pymunk.pygame_util import DrawOptions

pygame.init()

WIDTH, HEIGHT = 900, 500
win = pygame.display.set_mode((WIDTH,HEIGHT))
pygame.display.set_caption("Game")

def ball_body():
    body = pymunk.Body(10, 80, body_type = pymunk.Body.KINEMATIC)
    body.position = (500, 300)
    body.velocity = (-25,0)
    shape = pymunk.Circle(body, 50)
    shape.color = (0,255,0, 255)
    space.add(body, shape)
    return shape

space = pymunk.Space()
options = DrawOptions(main_background)

space.gravity = (0, 20)
fb_body = ball_body()
space.debug_draw(options)
...

I want to be able to see the collision circle or the collision box.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • I am pretty sure that [Pymunk tutorial section](http://www.pymunk.org/en/latest/tutorials.html) has a few videos that show how to combine `pymunk` with `pygame`, did you look at those? – Matiiss Nov 01 '21 at 13:44
  • Also make sure to check the Pymunk examples, for example this one which is more or less like the pymunk tutorial: https://github.com/viblo/pymunk/blob/master/examples/slide_and_pinjoint.py – viblo Nov 05 '21 at 14:50

0 Answers0