Static Circle Pymunk
Posted: Fri Jul 16, 2010 7:42 am
Hi Guys, Im trying to do a simple static circle and some balls colliding with it, but when I use the method space.add_static(body, shape) is given an error. Maybe is not the correct way to do static circle with colisions....
this is the code Im using to draw the small balls and the main static circle called group:
Hope someone can give me a advice.... 
this is the code Im using to draw the small balls and the main static circle called group:
Code: Select all
def add_ball(space): #balls
mass = 1
radius = 10
inertia = pm.moment_for_circle(mass, 0, radius, Vec2d(0,0))
body = pm.Body(mass, inertia)
x = random.randint(120,380)
body.position = x, 550
shape = pm.Circle(body, radius, Vec2d(0,0))
space.add(body, shape)
return shape
def add_group(space): #groups
mass = 1
radius = 40
inertia = pm.moment_for_circle(mass, 0, radius, Vec2d(0,0))
body = pm.Body(mass, inertia)
x = random.randint(120,380)
#y = random.randint(480,120)
body.position = x, 550
shape = pm.Circle(body, radius, Vec2d(0,0))
space.add(body, shape)
#space.add_static(body, shape)
return shape
def draw_ball(screen, ball): #draw the falling balls to teh screen
p = int(ball.body.position.x), 600-int(ball.body.position.y)
pygame.draw.circle(screen, (0, 255, 072), p, int(ball.radius), 0)
def draw_group(screen, ball): #draw the static group on the screen
p = int(ball.body.position.x), 600-int(ball.body.position.y)
pygame.draw.circle(screen, (0, 136, 252), p, int(ball.radius), 0)
