コード例 #1
0
    def __init__(self, one, two):
        b1 = None
        b2 = None

        self.one = one
        if one != None:
            one.addCement(self)
            b1 = one.body

        self.two = two
        if two != None:
            two.addCement(self)
            b2 = two.body

        self.joint = OdeFixedJoint(one.world.world)
        self.joint.attach(b1, b2)
        self.joint.set()
        self.active = True
コード例 #2
0
    def __init__(self,
                 brick,
                 color,
                 tileDir,
                 thickness,
                 density,
                 unglueThreshold=None,
                 shatterLimit=None,
                 shatterThreshold=None,
                 noSetup=False):
        if noSetup: return

        depth = thickness / 2
        world = brick.world
        parent = brick.parent
        size = entrywiseMult(vecInvert(tileDir),
                             brick.size) + (vecBasic(tileDir) * depth)
        pos = brick.node.getPos() + entrywiseMult(
            tileDir, brick.size) + (vecFromList(tileDir) * depth)
        self.tileDir = tileDir
        if unglueThreshold == None: unglueThreshold = 5
        if shatterThreshold == None: shatterThreshold = 10
        dir = getNeutralDir()

        Box.__init__(self, world, parent, color, pos, dir, size, density,
                     unglueThreshold, shatterLimit, shatterThreshold)

        self.thickness = thickness
        self.brick = brick
        self.brick.addTile(self)

        # Glue to brick.
        self.glue = OdeFixedJoint(self.world.world)
        self.glue.attachBodies(self.body, brick.body)
        self.glue.set()

        # Adjust collision bitmasks.
        self.geom.setCategoryBits(GameObject.bitmaskTileGlued)
        self.geom.setCollideBits(GameObject.bitmaskAll & ~GameObject.bitmaskBox
                                 & ~GameObject.bitmaskTileGlued
                                 & ~GameObject.bitmaskTile)