Beispiel #1
0
def get_border_shape_def(world_size, restitution, friction, density):
    """Return Box2D shape def for the screen borders."""
    shape = box2d.b2EdgeChainDef()
    shape.setVertices_b2Vec2((p2b_coor((1,1)),
                                 p2b_coor((world_size[0]-1,1)),
                                 p2b_coor((world_size[0]-1,world_size[1]-1)), 
                                 p2b_coor((1, world_size[1]-1))))
    shape.restitution = restitution
    shape.friction    = friction
    shape.density     = density

    return shape
Beispiel #2
0
 def make_edge(svgpath):
     r = []
     #print svgpath.transform
     #if not svgpath.id.startswith('ground'): return None
     for loop in svgpath.path:
         bd = box2d.b2BodyDef()
         bd.position = (0,0)
         sd = box2d.b2EdgeChainDef()
         data = [svgpath.transform((x[0], x[1])) for x in list(reversed(loop))]
         data = [(x[0]*settings.scale, x[1]*settings.scale) for x in data]
         #pprint(data)
         sd.setVertices(data)
         sd.isALoop = False
         sd.density = 1.0
         sd.friction = 1.75
         sd.restitution = 0.1
         body = self.world.CreateBody(bd)
         shape = body.CreateShape(sd)
         r.append((body,shape))
     return r
Beispiel #3
0
#!/usr/bin/python2.6
Beispiel #4
0
#!/usr/bin/python2.6