Exemplo n.º 1
0
 def __init__(self, radius, local_position=(0,0), colour=(1,1,1),
            density=None, friction=None, restitution=None):
     self.shape = b2CircleDef()
     super(Circle, self).__init__(shape=b2CircleDef(), colour=colour,
                                  density=density, friction=friction,
                                  restitution=restitution)
     self.shape.localPosition = local_position
     self.shape.radius = radius
Exemplo n.º 2
0
def setup_ball():
    bodydef = b2BodyDef()
    bodydef.position = b2Vec2(W * 0.33, H * 0.7)
    body = world.CreateBody(bodydef)
    cdef = b2CircleDef()
    cdef.radius = BOX_SIZE
    cdef.density = 0.01
    cdef.restitution = 0.3
    cdef.friction = 0.3
    body.CreateShape(cdef)
    body.SetMassFromShapes()
    return body
Exemplo n.º 3
0
def circle_def(radius,
        center=(0, 0),
        density=1,
        restitution=0.1,
        friction=2):
    s = b2CircleDef()
    s.radius = radius
    s.localPosition = b2Vec2(*center)
    s.density = density
    s.restitution = restitution
    s.friction = friction
    return s
Exemplo n.º 4
0
 def create_body(self, pos):
     bodydef = b2BodyDef()
     bodydef.position = b2Vec2(*pos)
     body = world.CreateBody(bodydef)
     cdef = b2CircleDef()
     cdef.radius = self.RADIUS
     cdef.density = 1.0
     cdef.restitution = 0.1
     cdef.friction = 0.5
     body.CreateShape(cdef)
     self.body = body
     body.SetBullet(True)
     body.SetMassFromShapes()
Exemplo n.º 5
0
def circle_def(radius,
        center=(0, 0),
        density=1,
        restitution=0.1,
        friction=2,
        groupindex=0):
    s = b2CircleDef()
    s.radius = radius
    s.localPosition = b2Vec2(*center)
    s.density = density
    s.restitution = restitution
    s.friction = friction
    s.filter.groupIndex = groupindex
    return s
Exemplo n.º 6
0
 def create_body(self, pos):
     bodydef = b2BodyDef()
     bodydef.position = b2Vec2(*pos)
     body = world.CreateBody(bodydef)
     cdef = b2CircleDef()
     cdef.radius = self.RADIUS
     cdef.density = 1.0  #вес тела
     cdef.restitution = 0.1 # прыгучесть, отскок
     cdef.friction = 0.5  # сила трения
     body.CreateShape(cdef)
     self.body = body
     body.SetBullet(True)
     body.SetMassFromShapes()
     self.body.userData = self