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


Python ParticleEffect.reset方法代码示例

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


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

示例1: Saucer

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reset [as 别名]
class Saucer(DirectObject):
    def __init__(self):
    
        self.ship = loader.loadModel("Art\ufo.egg")
        self.beam = loader.loadModel("Art\eam.egg")
        self.health = 100
      
        #Dummy is used to position the tractor beam collisionsphere
        self.dummy = NodePath('dummy')
        self.dummy.reparentTo(render)
        
        #Dummy2 used to position abductees
        self.dummy2 =  NodePath('dummy2')
        self.dummy2.reparentTo(render)

        self.beam.reparentTo(self.dummy2)
        
        self.glownode = self.ship.find("**/l_glownode")
        self.glownode.setColor(0,0,.5,1)
        
        self.glownode2 = self.ship.find("**/r_glownode")
        self.glownode2.setColor(0,0,.5,1)
            
        self.ship.reparentTo(render)
        self.ship.setScale(1)
        #self.ship.setH(180)
        self.ship.setPos(0,0,25)
        self.dummy.setPos(0,0,25)
        self.dummy2.setPos(0,0,25)
        
        #list of things currently abducting
        self.abductlist = []
        self.animals = []
        self.inanimates = []
        taskMgr.add(self.abductTask, "abductTask")
        taskMgr.add(self.lightTask, "lightTask")
        self.stuntime = 30
        self.stunbase = 30
        self.updown = False
        self.beamspeed = 1
        self.basebeamspeed = 2
        
        self.collected = 0
        
        self.beamon = True
        
        taskMgr.add(self.particleTask, "shipparticleTask")

        self.mydir = os.path.abspath(sys.path[0])
        self.mydir = Filename.fromOsSpecific(self.mydir).getFullpath()
        self.mydir = Filename(self.mydir)
        #self.mydir = self.mydir.toOsSpecific()
        
        self.abductp = ParticleEffect()
        self.abductp.loadConfig(self.mydir + '/abduct.ptf')
        self.pcount = 0
        self.particletime = 60 #Must be integer 

    def pickUp(self,object):   #Pick up another pickupable 
        if object.stuncount < self.stuntime:
            object.stunned = True
        else:
            if (len(self.abductlist) < 15):
                if object.type1 == 'inanimate':
                    self.inanimates.append(object)
                elif object.type1 == 'hostile':
                    self.inanimates.append(object)
                elif object.type1 == 'animal':
                    self.animals.append(object)
                    
                self.findSpeed()
                
                object.resetStun()
                object.abduct = True
                self.abductlist.append(object)
                object.playPickupSound()
                object.pickup.reparentTo(self.dummy2)
                object.pickup.setHpr(0,0,0)
                object.pickup.setPos(0,0,-37)
            else:
                print ("Pickup list full.")
    
    def drop(self,env): #Drop all
        for object in self.abductlist:
            object.abduct = False
            object.pickup.wrtReparentTo(env)
            #object.pickup.setPos(self.dummy2.getX(),self.dummy2.getY(),self.dummy2.getZ())
        self.abductlist[:] = []
 
    def lightTask(self,task):
        if not self.beamon:
            self.glownode.setColor(.1,.06,.92,1)
            self.glownode2.setColor(.1,.06,.92,1)
        if self.beamon:
            s = self.beamspeed/25     
            self.glownode.setColor(.12 - s/10,1 - s,.08 - s/10,1)
            self.glownode2.setColor(.12 - s/10,1 - s,.08- s/10,1)
        return task.cont
            
    def abductTask(self,task):
#.........这里部分代码省略.........
开发者ID:KipEnyan,项目名称:UFO-Game,代码行数:103,代码来源:saucer.py

示例2: Enemy

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

#.........这里部分代码省略.........
        diff = angle - hpr.x 

        if diff > 180.0:
            diff = diff - 360

        if diff < -180.0:
            diff = diff + 360

        if diff > 5.0:
            diff = 5.0
        if diff < -5.0:
            diff = -5.0

        new = Vec3(diff, 0, 0) + hpr
        #self.np.setHpr(new)
        
        # move forward
        r = radians(new.x)
        curr = self.np.getPos()
        diff = Vec3(self.movespeed * cos(r), self.movespeed * sin(r), 0)
        self.np.setPos(curr + diff)"""

        if self.hp < 0.0 and self.dead == 0.0:
            self.dead = time 
            self.app.scene.remove(self)
            # Create particle effect before we go
            self.dnp.setPos(self.np.getPos())
            self.particles.start(parent = self.dnp, renderParent = self.app.render)
            self.np.detachNode()

            # Drop some loot
            self.app.item_manager.add_item(self.np.getPos(), "soul", self.level)
            # Give the player some points
            self.app.player.score = self.app.player.score + 100

    def apply_effect(self, target, timer):
        if self.last_activated - timer + self.activate_delay < 0.0:
            self.last_activated = timer
            target.hp = target.hp - self.damage
        if target.np.getName()[0] == 't':
            target.pursuers.append(self)
            #self.ai_b = self.ai_char.getAiBehaviors()
            #self.ai_b.pursue(self.np.getPos())
            self.ai_b.pauseAi("pursue")

    def load_particle_config(self):
        self.particles = ParticleEffect()
        self.particles.reset()
        self.particles.setPos(0.000, 0.000, 0.000)
        self.particles.setHpr(0.000, 0.000, 0.000)
        self.particles.setScale(1.000, 1.000, 1.000)
        p0 = Particles('particles-1')
        # Particles parameters
        p0.setFactory("PointParticleFactory")
        p0.setRenderer("SpriteParticleRenderer")
        p0.setEmitter("SphereVolumeEmitter")
        p0.setPoolSize(20)
        p0.setBirthRate(0.0100)
        p0.setLitterSize(20)
        p0.setLitterSpread(0)
        p0.setSystemLifespan(1.0100)
        p0.setLocalVelocityFlag(1)
        p0.setSystemGrowsOlderFlag(1)
        # Factory parameters
        p0.factory.setLifespanBase(1.0000)
        p0.factory.setLifespanSpread(0.0000)
        p0.factory.setMassBase(1.0000)
        p0.factory.setMassSpread(0.0100)
        p0.factory.setTerminalVelocityBase(1200.0000)
        p0.factory.setTerminalVelocitySpread(0.0000)
        # Point factory parameters
        # Renderer parameters
        p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
        p0.renderer.setUserAlpha(0.05)
        # Sprite parameters
        p0.renderer.setTexture(self.app.loader.loadTexture('effects/dust.png'))
        p0.renderer.setColor(Vec4(1.00, 0.10, 0.10, 0.50))
        p0.renderer.setXScaleFlag(2)
        p0.renderer.setYScaleFlag(2)
        p0.renderer.setAnimAngleFlag(0)
        p0.renderer.setInitialXScale(0.100 * self.level)
        p0.renderer.setFinalXScale(0.200 * self.level)
        p0.renderer.setInitialYScale(0.100 * self.level)
        p0.renderer.setFinalYScale(0.200 * self.level)
        p0.renderer.setNonanimatedTheta(0.0000)
        p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPBLENDLINEAR)
        p0.renderer.setAlphaDisable(0)
        # Emitter parameters
        p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
        p0.emitter.setAmplitude(1.0000)
        p0.emitter.setAmplitudeSpread(0.0000)
        p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
        p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
        p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
        # Sphere Volume parameters
        p0.emitter.setRadius(0.1000)
        self.particles.addParticles(p0)
        f0 = ForceGroup('gravity')
        # Force parameters
        self.particles.addForceGroup(f0)
开发者ID:michaeltchapman,项目名称:alem,代码行数:104,代码来源:enemy.py

示例3: World

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reset [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: Lvl03

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reset [as 别名]
class Lvl03(DirectObject):
    def start(self):
        base.disableMouse() #turn off mouse camera control
        base.enableParticles()
	
	self.music = loader.loadMusic("models/gamedev/DEC.mp3")
	self.music.play()
	
        camera.setPosHpr(Vec3(98,-390,90), Vec3(0,-5,0))
        self.ballNum = 10
	self.setupStage()
        self.loadModels()
        self.setupLighting()
        self.setupCollisions()
        self.setupIntervals()
	
	taskMgr.add(self.ballMovementTask,'ballMoveTask')
        
        self.gameLen = 30
        
	self.player1Weapon = ""
	self.player2Weapon = ""
	
        #hud = OnscreenImage(image = 'models/gamedev/lvl2hud.jpg', pos = (0,1,20),scale=5.0)
        #hud.reparentTo(render)
        
        globalClock.reset()
        
        self.timer = OnscreenText("%d" % (self.gameLen-globalClock.getRealTime(),), pos = (98,145), scale = 18.0)
        self.timer.setColor(1,1,1)
        taskMgr.add(self.clockTask,"clockTask")
        
        self.player1Score = 0
        self.player2Score = 0
        
        self.nodeCount1 = 0
        self.nodeCount2 = 0
	
	self.player1Invincible = 0
        self.player2Invincible = 0
	
	self.jNP = self.playerModel.exposeJoint(None,"modelRoot","ikHandle2")
	self.jNP2 = self.playerModel2.exposeJoint(None,"modelRoot","ikHandle2")
	
        self.climbing1 = 0
        self.climbing2 = 0
        
        self.speed1 = 3.0
        self.speed2 = 3.0
        
        self.ignoreColl= 0
        
        self.player1IsColliding = 0
        self.player2IsColliding = 0
        
        taskMgr.doMethodLater(self.gameLen, self.endGame,'gameFinished')
        
        #taskMgr.doMethodLater(self.gameLen/2.0,self.changeMusic,'musicSwitch')
        
        
        #setup key controls
        self.accept("escape",sys.exit)
        #self.acceptOnce("space",self.drop)
        # Player 1 movement
        
        self.acceptOnce("a",self.left)
        self.acceptOnce("d",self.right)
        
        self.accept("a-up",self.stopLeft)
        self.accept("d-up",self.stopRight)
        
        self.acceptOnce("w", self.jump)

        
        #Player 2 movement keys
        #self.accept("l",self.fall2)
        
        self.acceptOnce("k",self.left2)
        self.acceptOnce(";",self.right2)
        
        self.accept("k-up",self.stopLeft2)
        self.accept(";-up",self.stopRight2)
        
        self.acceptOnce("o", self.jumpT2)
        
    def setupStage(self):
	self.ball = []
	self.movement = []
	for i in range(self.ballNum+1):
		z=random.randint(1,2)
		if z ==1:
			z=-1
		else:
			z=1
		weapBalls.define(self.ball,i,render)
		self.movement.append(Vec3(random.random()*z,0,random.random()*z))
		#self.movement[i].Vec3(random.randint(1,3),0,random.randint(1,3))
		
	self.background2 = OnscreenImage(image = 'models/gamedev/frozenbg.JPG', pos = (98,10,0),scale=500)
	self.background2.detachNode()
#.........这里部分代码省略.........
开发者ID:CarlosPlusPlus,项目名称:rpi-undergrad,代码行数:103,代码来源:LVL03.py

示例5: World

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

#.........这里部分代码省略.........
            file.write(("-" * depth) + item.getName() + ": \n")
        # print(("-" * depth) + item.getName() + ": ")
        for i in range(item.getNumNodes()):
            if file:
                file.write((" " * depth) + "+" + item.getNode(i).getName() + ": " + str(item.getNode(i).getClassType()) + "\n")
            # print((" " * depth) + "+" + item.getNode(i).getName() + ": " + str(item.getNode(i).getClassType()))
        for i in range(item.getNumChildren()):
            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
开发者ID:Splime,项目名称:ProjectThree,代码行数:70,代码来源:world.py


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