Пример #1
0
class Sphere(object):
    def __init__(self, world, pos, size, mass):
        self.world = world
        self.pos = pos
        # Create a body inside the world
        self.body = Body(world)
        M = Mass()
        M.setSphere(2500.0, size)
        M.mass = mass
        self.body.setMass(M)
        self.body.setPosition(pos)
        # draw body
        self.rbody = sphere(pos=pos, radius=size)

    def getPosition(self):
        return self.body.getPosition()

    def getLinearVel(self):
        return self.body.getLinearVel()

    def addForce(self, force):
        return self.body.addForce(force)

    def static(self):
        self.sj = BallJoint(self.world)
        self.sj.attach(self.body, environment)
        self.sj.setAnchor(self.pos)

    def joint(self, body):
        self.j = BallJoint(self.world)
        self.j.attach(self.body, body.body)
        self.j.setAnchor( body.pos )

    def draw(self):
        self.rbody.pos = self.getPosition()
Пример #2
0
 def joint(self, body):
     self.j = BallJoint(self.world)
     self.j.attach(self.body, body.body)
     self.j.setAnchor( body.pos )
Пример #3
0
 def static(self):
     self.sj = BallJoint(self.world)
     self.sj.attach(self.body, environment)
     self.sj.setAnchor(self.pos)