コード例 #1
0
    def clientCommonObject(self, type, commonId, pos, hpr, sizeX, sizeY, moveDistance):
        data = self.createCommonObject(type, commonId, pos, hpr, sizeX, sizeY, moveDistance)
        index = data[1]
        if type == 3:
            cross = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == cross:
                    base.sfxPlayer.setCutoffDistance(240)
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    windmillSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Windmill_Loop.ogg')
                    windMillSoundInterval = SoundInterval(windmillSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    windMillSoundInterval.loop()
                    self.physicsSfxDict[index] = (windmillSfx, windMillSoundInterval)
                    break

        else:
            if type == 4:
                box = self.commonObjectDict[commonId][2]
                for pair in self.odePandaRelationList:
                    pandaNodePathGeom = pair[0]
                    odeBody = pair[1]
                    if odeBody == box:
                        self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                        moverSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Moving_Barrier.ogg')
                        moverSoundInterval = SoundInterval(moverSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                        moverSoundInterval.start()
                        self.physicsSfxDict[index] = (moverSfx, moverSoundInterval, index)
                        break
コード例 #2
0
    def clientCommonObject(self, type, commonId, pos, hpr, sizeX, sizeY, moveDistance):
        data = self.createCommonObject(type, commonId, pos, hpr, sizeX, sizeY, moveDistance)
        index = data[1]
        if type == 3:
            cross = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == cross:
                    base.sfxPlayer.setCutoffDistance(240)
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    windmillSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Windmill_Loop.ogg')
                    windMillSoundInterval = SoundInterval(windmillSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    windMillSoundInterval.loop()
                    self.physicsSfxDict[index] = (windmillSfx, windMillSoundInterval)
                    break

        elif type == 4:
            box = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == box:
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    moverSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Moving_Barrier.ogg')
                    moverSoundInterval = SoundInterval(moverSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    moverSoundInterval.start()
                    self.physicsSfxDict[index] = (moverSfx, moverSoundInterval, index)
                    break
コード例 #3
0
 def __init__(self):
     ShowBase.__init__(self)
     getModelPath().appendDirectory("data")
     self.AST_INIT_VEL = 0.6
     self.score = 0
     self.lives = 5
     self.BULLET_LIFE = 1.5
     self.BULLET_SPEED = 15
     self.BULLET_REPEAT = .2
     self.AST_VEL_SCALE = 1.2
     self.disableMouse()
     #self.ss = OnscreenText(text="0", parent=base.a2dTopLeft, pos=(0.07, -.06 * 1 - 0.1),fg=(1, 1, 1, 1), align=TextNode.ALeft, shadow=(0, 0, 0, 0.5), scale=.12)
     self.ss = OnscreenText(text="0",
                            parent=base.a2dTopLeft,
                            pos=(0.2, -0.1),
                            scale=0.08,
                            fg=(1, 1, 1, 1))
     # self.ll = OnscreenText(text="5", parent=base.a2dTopLeft, pos=(2.4, -1.76 * 1 - 0.1),fg=(1, 1, 1, 1), align=TextNode.ALeft, shadow=(0, 0, 0, 0.5), scale=.12)
     self.ll = OnscreenText(text="5",
                            parent=base.a2dTopLeft,
                            pos=(2.5, -1.95),
                            scale=0.08,
                            fg=(1, 1, 1, 1))
     self.setBackgroundColor((0, 0, 0, 1))
     self.bg = loadObject("stars.png",
                          scale=146,
                          depth=200,
                          transparency=False)
     self.ship = loadObject("ship.png")
     self.setVelocity(self.ship, LVector3.zero())
     self.ship.hide()
     self.keys = {"turnLeft": 0, "turnRight": 0, "accel": 0, "fire": 0}
     self.accept("escape", sys.exit)
     self.accept("arrow_left", self.setKey, ["turnLeft", 1])
     self.accept("arrow_left-up", self.setKey, ["turnLeft", 0])
     self.accept("arrow_right", self.setKey, ["turnRight", 1])
     self.accept("arrow_right-up", self.setKey, ["turnRight", 0])
     self.accept("arrow_up", self.setKey, ["accel", 1])
     self.accept("arrow_up-up", self.setKey, ["accel", 0])
     self.accept("space", self.setKey, ["fire", 1])
     self.gameon = 0
     self.gton = 0
     self.startgame()
     mySound = loader.loadSfx("music.wav")
     myInterval = SoundInterval(mySound, loop=1)
     myInterval.loop()
コード例 #4
0
class VineBat(NodePath, DirectObject):
    notify = DirectNotifyGlobal.directNotify.newCategory('VineBat')
    notify.setDebug(True)
    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum
        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField
        gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)
        self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2], self.RADIUS)
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)
        self.screechSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.ogg')
        self.flySfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.ogg')
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx, node=self, listenerNode=base.localAvatar, seamlessLoop=True, volume=0.5, cutOff=240)
        self.reparentTo(render)
        self.startedFlying = False
        self.warnedForThisLap = False
        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX - endX) / self.timeToTraverseField
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        self.notify.debug('treasuerGrabbed')
        messenger.send('VineBatGrabbed', [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        self.warnedForThisLap = False

    def checkScreech(self):
        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True
コード例 #5
0
ファイル: VineBat.py プロジェクト: ghost4499/toontown-online
class VineBat(NodePath, DirectObject):
    notify = DirectNotifyGlobal.directNotify.newCategory('VineBat')
    notify.setDebug(True)
    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum
        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField
        gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode.SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)
        self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                          self.RADIUS)
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)
        self.screechSfx = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3')
        self.flySfx = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav')
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx,
                                           node=self,
                                           listenerNode=base.localAvatar,
                                           seamlessLoop=True,
                                           volume=0.5,
                                           cutOff=240)
        self.reparentTo(render)
        self.startedFlying = False
        self.warnedForThisLap = False
        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX - endX) / self.timeToTraverseField
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        self.notify.debug('treasuerGrabbed')
        messenger.send('VineBatGrabbed', [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        self.warnedForThisLap = False

    def checkScreech(self):
        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True
コード例 #6
0
ファイル: VineBat.py プロジェクト: satire6/Anesidora
class VineBat(NodePath.NodePath, DirectObject):
    """
    Treasures toons can pickup swinging from vine to vine.  Based on MazeTreasure
    """

    notify = DirectNotifyGlobal.directNotify.newCategory("VineBat")
    notify.setDebug(True)

    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        """Constructor for VineBat.

        batIndex -- [0..2]
        timeToTraverseField -- in seconds, time to traverse field, shorter = faster

        """

        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum

        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField

        #import pdb; pdb.set_trace()
        gameAssets = loader.loadModel("phase_4/models/minigames/vine_game")
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode.SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        #self.batModel.setH(180)

        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        #bat1.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        #self.batModel.setScale(0.35)

        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)

        # Make a sphere, name it uniquely, and child it
        # to the nodepath.
        self.sphereName = "batSphere-%s-%s" % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                          self.RADIUS)
        # Make the sphere intangible
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)

        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()

        # Add a hook looking for collisions with localToon
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)

        # now that the treasure and sphere have been placed, flatten the
        # whole silly thing
        #self.flattenLight()

        self.screechSfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3")

        #self.flySfx = base.loadSfx("phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.mp3")
        self.flySfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav")
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx,
                                           node=self,
                                           listenerNode=base.localAvatar,
                                           seamlessLoop=True,
                                           volume=0.5,
                                           cutOff=240)
        self.reparentTo(render)

        self.startedFlying = False
        self.warnedForThisLap = False

        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX -
                              endX) / self.timeToTraverseField  # in ft/s
        #self.warnDistance = 3 * self.velocity # in feet
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        # announce that this treasure was grabbed
        self.notify.debug('treasuerGrabbed')
        messenger.send("VineBatGrabbed", [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        # disable collisions
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        """Start the bat flying."""
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        """Stop the bat flying."""
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        """Called when he starts his lap from the right."""
        self.warnedForThisLap = False

    def checkScreech(self):
        """Check if we should screech to warn the player we are coming."""

        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                # screech only when we're to the right of the player
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True