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
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
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
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()
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
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