当前位置: 首页>>代码示例>>Python>>正文


Python ParticleEffect.setLightOff方法代码示例

本文整理汇总了Python中direct.particles.ParticleEffect.ParticleEffect.setLightOff方法的典型用法代码示例。如果您正苦于以下问题:Python ParticleEffect.setLightOff方法的具体用法?Python ParticleEffect.setLightOff怎么用?Python ParticleEffect.setLightOff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在direct.particles.ParticleEffect.ParticleEffect的用法示例。


在下文中一共展示了ParticleEffect.setLightOff方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_particles

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setLightOff [as 别名]
 def load_particles (self, name):
     p = ParticleEffect ()
     p.loadConfig (Filename (name))
     p.setLightOff () 
     p.setTransparency (TransparencyAttrib.MAlpha) 
     p.setBin ('fixed', 0) 
     p.setDepthWrite (False)
     p.setShaderOff ()
     return p
开发者ID:arximboldi,项目名称:pigeoncide,代码行数:11,代码来源:kill.py

示例2: Vehicle

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setLightOff [as 别名]

#.........这里部分代码省略.........
        if self.keyMap["backwards"] and not (self.keyMap["forward"] or self.keyMap["boost"]):
            if self.direction == Vehicle.FORWARDS:
                newSpeed = self.speed + (self.bkwdsAccel + self.deccel) * elapsed
            else:
                newSpeed = self.speed + self.bkwdsAccel * elapsed
            if newSpeed < self.maxBkwdsSpeed:
                self.speed = self.maxBkwdsSpeed
            else:
                self.speed = newSpeed

        # Even if no key is held down, we keep moving!
        if (not self.keyMap["forward"] and not self.keyMap["backwards"] and not self.keyMap["boost"]) or (
            self.keyMap["forward"] and self.keyMap["backwards"] and self.keyMap["boost"]
        ):
            if self.direction == Vehicle.FORWARDS:
                newSpeed = self.speed + self.deccel * elapsed
            else:
                newSpeed = self.speed - self.deccel * elapsed

            if self.direction == Vehicle.FORWARDS:
                if newSpeed < 0:
                    self.speed = 0
                else:
                    self.speed = newSpeed
            if self.direction == Vehicle.BACKWARDS:
                if newSpeed > 0:
                    self.speed = 0
                else:
                    self.speed = newSpeed

        # Now actually change position
        if self.direction != Vehicle.STOPPED:
            dist = self.speed * elapsed
            angle = deg2Rad(self.getH())
            dx = dist * math.sin(angle)
            dy = dist * -math.cos(angle)
            # self.setPos(self.getX() + dx, self.getY() + dy, self.getZ())
            self.setX(self.getX() + dx)
            self.setY(self.getY() + dy)

        # Next, activate animation if necessary
        isMoving = self.isTurning or (self.direction != Vehicle.STOPPED)
        if not wasMoving and isMoving:
            self.loop("drive")
        elif not isMoving:
            self.stop()
            self.pose("drive", 4)

        # Collisions! Yay?
        print "(%i, %i, %i)" % (self.getX(), self.getY(), self.getZ())
        base.cTrav.traverse(self.world.env)
        # print "(%i, %i, %i)"%(self.getX(), self.getY(), self.getZ())
        # Grab our collision entries
        # entries = []
        # for i in range(self.world.playerGroundHandler.getNumEntries()):
        # entry = self.world.playerGroundHandler.getEntry(i)
        # entries.append(entry)
        # This code got copied from Roaming Ralph
        # entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(), x.getSurfacePoint(render).getZ()))
        # if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
        # self.setZ(entries[0].getSurfacePoint(render).getZ())
        # if (len(entries)>0):
        # print "Hahahaha, nooope"
        # self.setPos(startpos)

        self.prevtime = task.time
        return Task.cont

    def collider(self, cEntry):
        pass

    def startBoosters(self):
        if self.boosterStartTime == -1:
            self.boosters.loadConfig(Filename("flamethrower4.ptf"))
            self.boosters.start(self)
            self.boosters.setPos(0, 200, 275)
            self.boosters.setHpr(180, 90, 0)
            self.boosters.setScale(200)
            self.boosters.setLightOff()
            self.accel = self.accel * 2
            self.keyMap["boost"] = 1
            self.boosterLight.setColor(VBase4(MAX_LIGHT, MAX_LIGHT, MAX_LIGHT, 1))
            taskMgr.add(self.checkBoosterEnd, "endBoosters")

    def checkBoosterEnd(self, task):
        if self.boosterStartTime == -1:
            self.boosterStartTime = task.time
            elapsed = 0
        else:
            elapsed = task.time - self.boosterStartTime

        if elapsed > BOOSTER_LENGTH:
            self.boosterLight.setColor(VBase4(0, 0, 0, 1))
            self.boosters.softStop()
            self.accel = self.accel / 2
            self.keyMap["boost"] = 0
            self.boosterStartTime = -1
            return Task.done
        else:
            return Task.cont
开发者ID:Splime,项目名称:ProjectThree,代码行数:104,代码来源:vehicle.py

示例3: World

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setLightOff [as 别名]

#.........这里部分代码省略.........
        self.fillLight = DirectionalLight("fillLight")
        self.fillLight.setColor((.05,.05,.05, 1))
        self.fillLightNP = render.attachNewNode(self.fillLight)
        self.fillLightNP.setHpr(30, 0, 0)
        
    def drive(self):
        """compound interval for driveing"""
        #some interval methods:
        # start(), loop(), pause(), resume(), finish()
        # start() can take arguments: start(starttime, endtime, playrate)
        dist = 5
        angle = deg2Rad(self.player.getH())
        dx = dist * math.sin(angle)
        dy = dist * -math.cos(angle)
        playerdrive = Parallel(self.player.posInterval(1, (self.player.getX() + dx, self.player.getY() + dy, 0)), \
            self.player.actorInterval("drive", loop=1, duration=2))
        playerdrive.start()
        
    def setupCollisions(self):
        #instantiates a collision traverser and sets it to the default
        base.cTrav = CollisionTraverser()
        self.cHandler = CollisionHandlerEvent()
        #set pattern for event sent on collision
        # "%in" is substituted with the name of the into object
        self.cHandler.setInPattern("ate-%in")
        
        cSphere = CollisionSphere((0,0,200), 450) #because the player is scaled way down
        self.playerRay = CollisionRay()
        self.playerRay.setOrigin(0,0,2000)
        self.playerRay.setDirection(0,0,-1)
        self.playerNode = CollisionNode("playerRay")
        self.playerNode.addSolid(self.playerRay)
        self.playerNode.setFromCollideMask(BitMask32.bit(0))
        self.playerNode.setIntoCollideMask(BitMask32.allOff())
        self.playerNodePath = self.player.attachNewNode(self.playerNode)
        self.playerNodePath.show()
        self.playerGroundHandler = CollisionHandlerFloor()
        self.playerGroundHandler.addCollider(self.playerNodePath, self.player)
        base.cTrav.addCollider(self.playerNodePath, self.playerGroundHandler)
        
        cNode = CollisionNode("player")
        cNode.addSolid(cSphere)
        cNode.setIntoCollideMask(BitMask32.allOff()) #player is *only* a from object
        #cNode.setFromCollideMask(BitMask32.bit(0))
        cNodePath = self.player.attachNewNode(cNode)
        #registers a from object with the traverser with a corresponding handler
        base.cTrav.addCollider(cNodePath, self.cHandler)
        i = 0
        for target in self.targets:
            cSphere = CollisionSphere((0,0,0), 2)
            cNode = CollisionNode("smiley")
            cNode.addSolid(cSphere)
            cNode.setIntoCollideMask(BitMask32.bit(1))
            cNode.setTag('target', str(i))
            cNodePath = target.attachNewNode(cNode)
            i += 1
    
    def lightModify(self, t, which_way):
        if which_way: #which_way == true then make it brighter
            value = t/100 * MAX_LIGHT
        else: #which_way == true then make it darker
            value = (100 - t)/100 * MAX_LIGHT
        for light in self.flameLights:
            light[0].setColor(VBase4(value,value,value,1))
        
    def startShoot(self):
        self.loadParticleConfig('flamethrower4.ptf')
        self.lightOff.finish()
        self.lightOn.start()
        
    def stopShoot(self):
        self.p1.softStop()
        self.p2.softStop()
        self.lightOn.finish()
        self.lightOff.start()
        
    def loadParticleConfig(self, file):
        self.p1.reset()
        self.p1 = ParticleEffect()
        self.p1.loadConfig(Filename(file))        
        self.p1.start(self.player)
        self.p1.setPos(-250, -700, 275)
        self.p1.setHpr(0, 90, 0)
        self.p1.setScale(200)
        self.p1.setLightOff()
        self.p2.reset()
        self.p2 = ParticleEffect()
        self.p2.loadConfig(Filename(file))        
        self.p2.start(self.player)
        self.p2.setPos(250, -700, 275)
        self.p2.setHpr(0, 90, 0)
        self.p2.setScale(200)
        self.p2.setLightOff()
        
    def eat(self, cEntry):
        """handles the player eating a smiley"""
        #remove target from list of targets
        self.targets.remove(cEntry.getIntoNodePath().getParent())
        #remove from scene graph
        cEntry.getIntoNodePath().getParent().remove()
开发者ID:Splime,项目名称:ProjectThree,代码行数:104,代码来源:tutorial8.py

示例4: Vehicle

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setLightOff [as 别名]

#.........这里部分代码省略.........
        entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(), x.getSurfacePoint(render).getZ()))
        if (len(entries)>0) and (entries[0].getIntoNode().getName()[:3] == "lot"):
            self.setZ(entries[0].getSurfacePoint(render).getZ())
            if entries[0].getIntoNode().getName() == "lot_ramp_top":
                if self.loc != entries[0].getIntoNode().getName():
                    slope_angle = math.asin((6 - 3.5) / (-8.845 + 14.923))
                    slope_angle = rad2Deg(math.sin(slope_angle))
                    P = slope_angle * math.cos(deg2Rad(self.getH()))
                    R = slope_angle * -math.sin(deg2Rad(self.getH()))
                    self.rampHprInterval.finish()
                    self.rampHprInterval = LerpFunc(self.rampInterval,
                                                    fromData=0,
                                                    toData=100,
                                                    duration=RAMP_INTERVAL_DURATION,
                                                    blendType='noBlend',
                                                    extraArgs=[(self.getP(),self.getR()),(P,R)],
                                                    name="rampInterval")
                    self.rampHprInterval.start()
                elif not self.rampHprInterval.isPlaying():
                    slope_angle = math.asin((6 - 3.5) / (-8.845 + 14.923))
                    slope_angle = rad2Deg(math.sin(slope_angle))
                    self.setP(slope_angle * math.cos(deg2Rad(self.getH())))
                    self.setR(slope_angle * -math.sin(deg2Rad(self.getH())))
            elif entries[0].getIntoNode().getName() ==  "lot_ramp_bottom":
                if self.loc != entries[0].getIntoNode().getName():
                    slope_angle = math.asin((3.5 - 0) / ( -32.715 - 12.56))
                    slope_angle = rad2Deg(math.sin(slope_angle))
                    P = slope_angle * math.sin(deg2Rad(self.getH()))
                    R = slope_angle * math.cos(deg2Rad(self.getH()))
                    self.rampHprInterval.finish()
                    self.rampHprInterval = LerpFunc(self.rampInterval,
                                                    fromData=0,
                                                    toData=100,
                                                    duration=RAMP_INTERVAL_DURATION,
                                                    blendType='noBlend',
                                                    extraArgs=[(self.getP(),self.getR()),(P,R)],
                                                    name="rampInterval")
                    self.rampHprInterval.start()
                elif not self.rampHprInterval.isPlaying():
                    slope_angle = math.asin((3.5 - 0) / ( -32.715 - 12.56))
                    slope_angle = rad2Deg(math.sin(slope_angle))
                    self.setP(slope_angle * math.sin(deg2Rad(self.getH())))
                    self.setR(slope_angle * math.cos(deg2Rad(self.getH())))
            else:
                if self.loc != entries[0].getIntoNode().getName():
                    self.rampHprInterval = LerpFunc(self.rampInterval,
                                                    fromData=0,
                                                    toData=100,
                                                    duration=RAMP_INTERVAL_DURATION,
                                                    blendType='noBlend',
                                                    extraArgs=[(self.getP(),self.getR()),(0,0)],
                                                    name="rampInterval")
                    self.rampHprInterval.start()
            self.loc = entries[0].getIntoNode().getName()
        #elif (len(entries)>0):
        #    print "Hahahaha, nooope"
        #    self.setPos(startpos)
        
        #Now that actual movement is done, deal with playing the right sound
        self.updateEngineSound()
        
        self.prevtime = task.time
        return Task.cont
    
    def startBoosters(self):
        if self.boosterStartTime == -1:
            self.totalGas = self.totalGas - 5
            self.boosters.loadConfig(Filename('flamethrower4.ptf'))        
            self.boosters.start(self)
            self.boosters.setPos(0, 8.5, 2)
            self.boosters.setHpr(180, 90, 0)
            self.boosters.setLightOff()
            self.maxSpeed = self.maxSpeed + BOOST_MAX_SPEED_BONUS
            self.speed = min(self.speed + 75, self.maxSpeed)
            self.accel = self.accel * BOOST_FACTOR
            self.keyMap["boost"] = 1
            self.boosterLight.setColor(VBase4(MAX_LIGHT,MAX_LIGHT,MAX_LIGHT,1))
            self.boostSound.play()
            taskMgr.add(self.checkBoosterEnd, "endBoosters")
        
    def checkBoosterEnd(self, task):
        if self.boosterStartTime == -1:
            self.boosterStartTime = task.time
            elapsed = 0
        else:
            elapsed = task.time - self.boosterStartTime
            
        if elapsed > BOOSTER_LENGTH:
            self.boosterLight.setColor(VBase4(0,0,0,1))
            self.boosters.softStop()
            self.accel = self.accel / BOOST_FACTOR
            self.keyMap["boost"] = 0
            self.boosterStartTime = -1
            self.maxSpeed = self.maxSpeed - BOOST_MAX_SPEED_BONUS
            self.speed = min(self.speed, self.maxSpeed)
            self.boostSound.stop()
            return Task.done        
        else:    
            return Task.cont
            
开发者ID:Splime,项目名称:ProjectThree,代码行数:103,代码来源:vehicle.py

示例5: World

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setLightOff [as 别名]

#.........这里部分代码省略.........
            self.dfs(item.getChild(i), depth + 1, file)
            
    def startDrain(self):
        if not self.flamethrowerActive:
            prevDraining = self.draining #previous value of draining
            if base.mouseWatcherNode.hasMouse():
                mpos = base.mouseWatcherNode.getMouse()
                self.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
                self.picker.traverse(self.staticRoot)
                if self.pq.getNumEntries() > 0:
                    self.pq.sortEntries()
                    for i in range(self.pq.getNumEntries()):
                        if self.pq.getEntry(i).getIntoNode().getTag('car') != "":
                            self.target = int(self.pq.getEntry(i).getIntoNode().getTag('car'))
                            self.draining = True
            #Start sounds if self.draining started
            if self.draining and not prevDraining:
                self.drainSound.play()

    def drain(self, task):
        if self.draining and task.time - self.drainTime > DRAIN_DELAY:
            carpos = self.staticCars[self.target].getPos()
            playerpos = self.player.getPos()
            dist = math.sqrt( (carpos[0] - playerpos[0])**2 + (carpos[1] - playerpos[1])**2 + (carpos[2] - playerpos[2])**2 )
            if self.gasList[self.target] > 0 and dist < DRAIN_DIST:
                if not self.gasPlaying:
                    self.gasP.reset()
                    self.gasP = ParticleEffect()  
                    self.gasP.loadConfig(Filename('oil.ptf'))        
                    self.gasP.start(self.player)
                    self.gasNode.lookAt(self.staticCars[self.target])
                    self.gasP.setPos(0,0,2)
                    self.gasP.setScale(1.5)
                    self.gasP.setLightOff()
                    self.gasPlaying = True
                    self.alan_var = False
                self.gasNode.lookAt(self.staticCars[self.target])
                self.gasP.setHpr(self.gasNode.getH() + 180, 90, 0)
                self.player.totalGas = self.player.totalGas + 1
                self.gasList[self.target] = self.gasList[self.target] - 1
            else:
                self.alan_var = True
            # print "TotalGas: " + str(self.player.totalGas)
            self.drainTime = task.time
        elif not self.draining or self.alan_var:
            self.gasP.softStop()
            self.drainSound.stop()
            self.gasPlaying = False
        return Task.cont
                     
    def stopDrain(self):
        self.draining = False
           
    def loseHealth(self, task):
        if task.time - self.gasLossTime > GAS_TIME:
            if self.player.direction != 0:
                self.player.totalGas = self.player.totalGas - self.gasLossRate
            elif self.flamethrowerActive:
                self.player.totalGas = self.player.totalGas - self.gasLossRate
            self.gasLossTime = task.time
            # print self.player.totalGas
        return Task.cont
           
    def mouseTask(self, task):
        j = -1
        if base.mouseWatcherNode.hasMouse():
开发者ID:Splime,项目名称:ProjectThree,代码行数:70,代码来源:world.py


注:本文中的direct.particles.ParticleEffect.ParticleEffect.setLightOff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。