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


Python ParticleEffect.setScale方法代码示例

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


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

示例1: smoke_emitter

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class smoke_emitter():
    def __init__(self, parent, _x, _y, _z):
        self.x = _x
        self.y = _y
        self.z = _z
        self.parent = parent
        self.p = ParticleEffect()
        self.load_config('steam.ptf')
        self.p.setScale(200)

    def load_config(self, file_name):
        self.p.cleanup()
        self.p = ParticleEffect()
        self.p.loadConfig(file_name)
        self.p.start(render)
        self.p.setPos(self.x, self.y, self.z)
        self.p.reparentTo(self.parent)
开发者ID:daFthawk,项目名称:group-3,代码行数:19,代码来源:smoke_emitter.py

示例2: World

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class World(DirectObject):
    def __init__(self):
        

        #More standard initialization
        self.accept('escape', sys.exit)
        self.accept('1', self.loadParticleConfig , ['spark.ptf'])
        
        
        self.accept('escape', sys.exit)
        base.disableMouse()
        camera.setPos(0,-20,2)
        base.setBackgroundColor( 0, 0, 0 )

        #This command is required for Panda to render particles
        base.enableParticles()
        self.t = loader.loadModel("models/stepipe")
        self.t.setPos(0,0,0)
        self.t.reparentTo(render)
        self.setupLights()
        self.p = ParticleEffect()
        self.loadParticleConfig('spark.ptf')
        self.p.setScale(3)

    def loadParticleConfig(self, file):
        #Start of the code from spark.ptf
        self.p.cleanup()
        self.p = ParticleEffect()
        self.p.loadConfig(Filename(file))        
        #Sets particles to birth relative to the teapot, but to render at toplevel
        self.p.start(self.t)
        self.p.setPos(-2.00, 0.000, 3.150)
    
    #Setup lighting
    def setupLights(self):
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.4, .4, .35, 1))
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3( 0, 8, -2.5 ) )
        directionalLight.setColor(Vec4( 0.9, 0.8, 0.9, 1 ) )
        #Set lighting on teapot so spark doesn't get affected
        self.t.setLight(self.t.attachNewNode(directionalLight))
        self.t.setLight(self.t.attachNewNode(ambientLight))
开发者ID:kridily,项目名称:fall_and_fix,代码行数:45,代码来源:sparp.py

示例3: __init__

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class PipeWires:
    """
    Creates self contained pipe objects with methods that create,
    reference, and destroy models, collision tubes, lights,
    particles, and ActionCommand sequences.
    """



    def __init__(self):

        #SoundIntervals
        #base = ShowBase()
        self.sound = loader.loadSfx("../audio/sparks.wav")
        self.sound.setLoop(True)
        self.sound.play()

        #pick file
        self.fileName = "../models/tunnelwires"
        
        #load model
        self.model = loader.loadModel(self.fileName)
        self.model.setScale(.0175)
        #print self.model.ls()

        self.nodePath = NodePath(self.model)
        self.model.reparentTo(render)
        self.key = self.model.getKey()


        ##self.addModel(bag)
        self.addPointLight(self.model)
        self.shaderEnabled = 0
        #self.addShader()        
        #self.addCollision()
        ##self.addParticle(self.model)

        base.enableParticles()

        self.particle = ParticleEffect()
        self.loadParticleConfig('../models/', 'spark.ptf')
        #self.loadParticleConfig("spark.ptf")

        self.addActionCommand("ru")
        self.type = "wires"

        #rotate by 0, 90, 180, or 270 degrees
        self.model.setR(random.randint(0,3)*90)
        #print self.model.getR()

    def addPointLight(self, pipe):
        """create a point light for pipe"""

        #The redpoint light and helper
        #RED
        # r = random.uniform(700, 900) / 1000
        # g = random.uniform(0, 300) / 1000
        # b = g

        #ORANGE
        r = 1
        b = random.randint(0,91)
        g = (b / 2) + 102
        b = b / 255.0
        g = g / 255.0
        self.helper = loader.loadModel("../models/sphere.egg.pz")

        self.helper.setColor( Vec4( r, g, b, 1 ) )
        self.helper.setPos(pipe.getPos())
        #print self.helper.getColor()

        #This is value is irrelevent at the moment unless I move the lights
        self.helper.setScale(.25*1) #must be greater than 0.001


        #optionally set location of light within pipe
        self.helper.setY(self.helper.getY()-50*35 ) #moves to inbetween segments
        self.helper.setZ(self.helper.getZ()-50*6 ) #makes 3 sided lights

        self.light = self.helper.attachNewNode( PointLight( "self.light" ) )
        self.light.node().setAttenuation( Vec3( .1, 0.04, 0.1 )/2.5 )
        self.light.node().setColor( Vec4( r, g, b, 1 ) )
        self.light.node().setSpecularColor( Vec4( 1 ) )
        self.helper.reparentTo( pipe )
        render.setLight( self.light )
        ###
        self.h = loader.loadModel("../models/sphere.egg.pz")
        self.h.setPos(0, -300, 200)
        self.h.setScale(.25*1)
        self.spl = self.h.attachNewNode( Spotlight( "self.spl") )
        self.spl.node().setColor( Vec4( 5, 5, 5, 1 ) )
        #self.spl.node().setAttenuation( Vec3( 0.003, 0.003, 0.003 ) )
        self.spl.lookAt(0, 20, -200)
        
        self.h.reparentTo( pipe)
        render.setLight( self.spl)
        

    ###def addModel(self, bag):
        """Adds the model to the pipe object"""        
#.........这里部分代码省略.........
开发者ID:kridily,项目名称:fall_and_fix,代码行数:103,代码来源:PipeWires.py

示例4: Vehicle

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class Vehicle(Actor):

    BACKWARDS = -1
    STOPPED = 0
    FORWARDS = 1

    def __init__(self, modelStr, driveStr, world):
        Actor.__init__(self, modelStr, {"drive": driveStr})
        self.world = world
        self.setScale(0.005)
        self.setH(180)
        self.reparentTo(render)
        self.prevtime = 0
        # some movement stats
        self.accel = 40.0
        self.deccel = -40.0
        self.bkwdsAccel = -10.0
        self.speed = 0.0
        self.maxSpeed = 100.0
        self.maxBkwdsSpeed = -40.0
        self.direction = Vehicle.STOPPED
        self.isTurning = False
        self.turnFactor = 4.0

    def setupBooster(self):
        # Booster Stuff
        self.boosters = ParticleEffect()
        self.boosterStartTime = -1
        self.boosterLight = PointLight("boostlight")
        self.boosterLight.setColor(VBase4(0, 0, 0, 1))
        self.boosterLight.setAttenuation(Point3(0, 0.001, 0.001))
        self.world.boosterLightNP = self.attachNewNode(self.boosterLight)
        self.world.boosterLightNP.setPos(0, 500, 275)
        self.world.boosterLightNP.setHpr(180, 90, 0)
        self.world.boosterLightNP.setScale(200)
        self.world.setWorldLight(self)

    def addKeyMap(self, keyMap):
        self.keyMap = keyMap
        keyMap["boost"] = 0

    def move(self, task):
        elapsed = task.time - self.prevtime

        startpos = self.getPos()  # Initial position
        wasMoving = self.isTurning or (self.direction != Vehicle.STOPPED)

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

        # Deal with turning
        if self.keyMap["left"]:
            self.setH(self.getH() + elapsed * self.speed * self.turnFactor)
            if self.direction != Vehicle.STOPPED:
                self.isTurning = True
        elif self.keyMap["right"]:
            self.setH(self.getH() - elapsed * self.speed * self.turnFactor)
            if self.direction != Vehicle.STOPPED:
                self.isTurning = True
        else:
            self.isTurning = False

        # Accelerating
        if (self.keyMap["forward"] and not self.keyMap["backwards"]) or self.keyMap["boost"]:
            if self.direction == Vehicle.BACKWARDS:
                newSpeed = self.speed + (self.accel - self.deccel) * elapsed
            else:
                newSpeed = self.speed + self.accel * elapsed
            if newSpeed > self.maxSpeed:
                self.speed = self.maxSpeed
            else:
                self.speed = newSpeed

        # Braking/Reversing
        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
#.........这里部分代码省略.........
开发者ID:Splime,项目名称:ProjectThree,代码行数:103,代码来源:vehicle.py

示例5: Enemy

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class Enemy():
    def __init__(self, pos, index, app, manager, level, style):
        self.position = pos
        self.app = app
        self.np = app.render.attachNewNode("enemy%d" % index)

        if style == 1:
            self.np.setColorScale(1.0, 1.0, 1.0, 1.0)
            self.movespeed = 2.5
            self.max_movespeed = 30
        else:
            self.movespeed = 0.5
            self.max_movespeed = 25

        if style == 2:
            self.activate_delay = 0.01
            self.np.setColorScale(0.6, 1.0, 1.0, 1.0)
        else:
            self.activate_delay = 0.1

        if style == 3:
            self.hp = 50 * level
            self.np.setColorScale(0.0, 1.0, 0.5, 1.0)
        else:
            self.hp = 100 * level

        if style == 4:
            self.damage = 20
            self.np.setColorScale(1.0, 1.0, 0.0, 1.0)
        else:
            self.damage = 10

        self.dead = 0.0
        self.level = level
        self.style = style
        self.particle_clean = False

        # this allows us to detach the instance nodepath
        # on death, but keep one with no model to attach particle effects
        self.dnp = app.render.attachNewNode("enemy_top%d" % index)

        self.np.setPos(self.position)

        self.np.setHpr(uniform(1,360),0,0)
        self.np.setScale(level)

        colsize = 3.0
        self.cn = self.np.attachNewNode(CollisionNode('enemy_cn_%d' % index))
        self.cs0 = CollisionSphere(0.0, colsize/2,0.0,colsize)
        self.cs1 = CollisionSphere(0.0, -colsize/2,0.0,colsize)
        self.cs2 = CollisionSphere(0.0, -colsize/3*4,0.0,colsize/2)
        self.cn.node().addSolid(self.cs0)
        self.cn.node().addSolid(self.cs1)
        self.cn.node().addSolid(self.cs2)
        #self.cn.show() # debug

        self.cqueue = CollisionHandlerQueue()
        app.cTrav.addCollider(self.cn, self.cqueue)

        self.cn.node().setIntoCollideMask(BitMask32(0x01))
        self.cn.node().setFromCollideMask(BitMask32(0x10))

        self.last_activated = 0.0

        manager.add_instance(self)


        # name, nodepath, mass, move_force, max_force
        self.ai_char = AICharacter('enemy_ai_%d' % index, self.np, 100, self.movespeed, self.max_movespeed)
        app.ai_world.addAiChar(self.ai_char)
        self.ai_b = self.ai_char.getAiBehaviors()
        self.ai_b.pursue(app.player.np)

        self.load_particle_config()
    
    def update(self, time):

        a = 0
        # Handle collsions
        for i in range(self.cqueue.getNumEntries()):
           collided_name = self.cqueue.getEntry(i).getIntoNodePath().getName()
           #handle bullets
           if collided_name[0] == 'b': 
               bullet = self.app.bullet_manager.get_bullet(collided_name)
               bullet.apply_effect(self)
               self.app.bullet_manager.remove_bullet(collided_name)

        if self.cqueue.getNumEntries() != 0:
            self.np.setColorScale(1.0, self.hp / 100.0, self.hp / 100.0, 1.0)
       
        """
        desired = self.app.player.position - self.np.getPos()
        angle = degrees(atan2(desired.y, desired.x))
        
        hpr = self.np.getHpr()
        if hpr.x > 360:
            hpr.x = hpr.x - 360
        if hpr.x < -360:
            hpr.x = hpr.x + 360

#.........这里部分代码省略.........
开发者ID:michaeltchapman,项目名称:alem,代码行数:103,代码来源:enemy.py

示例6: Particle

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class Particle():
    
    def __init__(self,file,name=None, pos=(0.0,0.0,0.0),scale=(1.0,1.0,1.0)):
        

        self.particleEffect = None
        self.configFile = file
        self.name = name
        self.position = pos
        self.scale = scale
        
        self.particleEffect = ParticleEffect(name)
        self.particleEffect.loadConfig(Filename(file))        

        self.particleEffect.setPos(pos[0], pos[1], pos[2])
        self.particleEffect.setScale(scale[0],scale[1],scale[2])
        
        base.enableParticles()


    
    def encode(self,doc):
        node = doc.createElement("particle")
        
        configFilename = doc.createElement("configFilename")
        configFilename.appendChild(doc.createTextNode(self.configFile))
        node.appendChild(configFilename)
        
        #CONSIDER: What happens if the name was none
        name = doc.createElement("name")
        name.appendChild(doc.createTextNode(self.name))
        node.appendChild(name)
        
        
        pos = doc.createElement("position")
        x_p = doc.createElement("x")
        x_p.appendChild(doc.createTextNode(str(self.position[0])))
        pos.appendChild(x_p)
        y_p = doc.createElement("y")
        y_p.appendChild(doc.createTextNode(str(self.position[1])))
        pos.appendChild(y_p)
        z_p = doc.createElement("z")
        z_p.appendChild(doc.createTextNode(str(self.position[2])))
        pos.appendChild(z_p)
        node.appendChild(pos)
        
        
        scale = doc.createElement("scale")
        x_s = doc.createElement("x")
        x_s.appendChild(doc.createTextNode(str(self.scale[0])))
        scale.appendChild(x_s)
        y_s = doc.createElement("y")
        y_s.appendChild(doc.createTextNode(str(self.scale[1])))
        scale.appendChild(y_s)
        z_s = doc.createElement("z")
        z_s.appendChild(doc.createTextNode(str(self.scale[2])))
        scale.appendChild(z_s)
        node.appendChild(scale)
        
        
        
        return node
    
    def decode(node):
        configFilename =None
        name =None
        pos = None
        scale = None
        x = 0
        y = 0
        z = 0 
        for n in node.childNodes:
            if n.localName == "configFilename":
                configFilename =  n.childNodes[0].data.strip()
            elif n.localName == "name":
                name =  n.childNodes[0].data.strip()
            elif n.localName == "position":
                for n1 in n.childNodes:
                    if n1.localName =="x":
                       x =  n1.childNodes[0].data.strip()
                    elif n1.localName =="y":
                       y =  n1.childNodes[0].data.strip()
                    elif n1.localName =="z":
                       z =  n1.childNodes[0].data.strip()
                    x = float(x)
                    y = float(y)
                    z = float(z)
                    pos = (x,y,z)
            elif n.localName == "scale":
                for n1 in n.childNodes:
                    if n1.localName =="x":
                       x =  n1.childNodes[0].data.strip()
                    elif n1.localName =="y":
                       y =  n1.childNodes[0].data.strip()
                    elif n1.localName =="z":
                       z =  n1.childNodes[0].data.strip()
                    x = float(x)
                    y = float(y)
                    z = float(z)
                    scale = (x,y,z)
#.........这里部分代码省略.........
开发者ID:wpesetti,项目名称:Orellia-Source,代码行数:103,代码来源:Particle.py

示例7: __init__

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

    def __init__(self, game):

        self.game = game

        self.shipPoint = NodePath(PandaNode("shipFloaterPoint"))
        self.shipPoint.reparentTo(render)

        self.x_pos = 0
        self.z_pos = 0

        self.x_speed = 0
        self.z_speed = 0

        self.x_pid = PID(3.0, 5.0, 1.0)
        self.z_pid = PID(3.0, 5.0, 1.0)

        self.model = Actor("data/ship.egg")

        self.model.setPos(0, 0, 0)
        self.model.setHpr(0, 0, 0)

        self.normal_speed = 3.5
        self.low_speed = 2

        self.speed = self.normal_speed

        self.cool_down = 0.1
        self.last_shoot = 0

        self.keyMap = {

            "up": 0,
            "down": 0,
            "left": 0,
            "right": 0,

            "brake": 0,

            "attack": 0,
        }

        # This list will stored fired bullets.
        self.bullets = []

        self.game.accept("mouse1", self.setKey, ["attack", 1])
        self.game.accept("mouse1-up", self.setKey, ["attack", 0])

        self.game.accept("shift-mouse1", self.setKey, ["attack", 1])
        self.game.accept("shift-mouse1-up", self.setKey, ["attack", 0])

        self.game.accept("x", self.setKey, ["attack", 1])
        self.game.accept("x-up", self.setKey, ["attack", 0])

        self.game.accept("c", self.setKey, ["brake", 1])
        self.game.accept("c-up", self.setKey, ["brake", 0])

        self.game.accept("arrow_up", self.setKey, ["up", 1])
        self.game.accept("arrow_up-up", self.setKey, ["up", 0])

        self.game.accept("arrow_down", self.setKey, ["down", 1])
        self.game.accept("arrow_down-up", self.setKey, ["down", 0])

        self.game.accept("arrow_left", self.setKey, ["left", 1])
        self.game.accept("arrow_left-up", self.setKey, ["left", 0])

        self.game.accept("arrow_right", self.setKey, ["right", 1])
        self.game.accept("arrow_right-up", self.setKey, ["right", 0])

    def setKey(self, key, value):
        self.keyMap[key] = value

    def draw(self):
        self.model.reparentTo(render)

        self.p = ParticleEffect()
        self.p.loadConfig(Filename('data/particles/fireish.ptf'))

        self.p.setR(180)
        self.p.setScale(0.25)
        # Sets particles to birth relative to the teapot, but to render at
        # toplevel
        self.p.start(self.model)
        self.p.setPos(0.000, 0.000, 0.000)

    def update(self, task):
        dt = globalClock.getDt()

        if self.model:

            # Movement

            if self.keyMap["brake"]:
                self.speed = self.low_speed
            else:
                self.speed = self.normal_speed

            if self.game.ship_control_type == 0:

#.........这里部分代码省略.........
开发者ID:JauriaStudios,项目名称:HostilGalaxy,代码行数:103,代码来源:ship.py

示例8: createEnvironment

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
 def createEnvironment(self):
     # Loads aquarium and sets it so player is stuck in it.
     
     self.enviroNode = render.attachNewNode( "EnviroNode" )
     self.enviroNode.setScale(1)
     self.enviroNode.setPosHpr(0,0,-30,  0,0,0)
     # Load second fish example
     self.fish2 = loader.loadModel("Models/clownFishModel.egg")
     self.fish2 = Actor('Models/clownFishModel.egg', {'swimming':'Models/clownFishAnim.egg'})
     self.fish2.loop('swimming')
     self.fish2.reparentTo(self.enviroNode)
     ##self.fish2Tex = loader.loadTexture("Textures/red.tif")
     ##self.fish2.setTexture(self.fish2Tex, 1)
     self.fish2.setScale(.7)
     self.fish2.setPos(50, 164.8, 44.15)
     ## self.fish2.place()
     # Sequences for Fish2 movement
     self.fish2PosInterval1 = self.fish2.posInterval(10,Point3(-50, 0, 70),startPos=Point3(50,0, 70))
     self.fish2PosInterval2 = self.fish2.posInterval(10,Point3(50, 0, 70),startPos=Point3(-50, 0, 70))
     self.fish2HprInterval1 = self.fish2.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))
     self.fish2HprInterval2 = self.fish2.hprInterval(3,Point3(0, 0, 0),startHpr=Point3(180, 0, 0))
     self.fish2move = Sequence(self.fish2PosInterval2, self.fish2HprInterval1, self.fish2PosInterval1, self.fish2HprInterval2, name="fish2move")        
     self.fish2move.loop()
     
     # Load third fish example
     self.fish3 = loader.loadModel("Models/smallSchoolFishModel.egg")
     self.fish3 = Actor('Models/smallSchoolFishModel.egg', {'swimming':'Models/smallSchoolFishAnim.egg'})
     self.fish3.loop('swimming')
     self.fish3.reparentTo(self.enviroNode)
     ## self.fish3Tex = loader.loadTexture("Textures/red.tif")
     ## self.fish3.setTexture(self.fish3Tex, 1)
     self.fish3.setScale(1.5)
     self.fish3.setPos(230, 50, 15)
     ## self.fish3.setHpr(0, 0, 0)
     ## self.fish3.place()
     # Sequences for Fish3 Movement
     self.fish3PosInterval1 = self.fish3.posInterval(10,Point3(230, 50, 25),startPos=Point3(150,50, 30))
     self.fish3PosInterval2 = self.fish3.posInterval(10,Point3(150, 50, 30),startPos=Point3(230, 50, 15))
     self.fish3HprInterval1 = self.fish3.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))
     self.fish3HprInterval2 = self.fish3.hprInterval(3,Point3(0, 0, 0),startHpr=Point3(180, 0, 0))
     self.fish3move = Sequence(self.fish3PosInterval2, self.fish3HprInterval1, self.fish3PosInterval1, self.fish3HprInterval2, name="fish3move")        
     self.fish3move.loop()
     
     # Load fourth fish example
     self.fish4 = loader.loadModel("Models/lionFishModel.egg")
     self.fish4 = Actor('Models/lionFishModel.egg', {'swimming':'Models/lionFishAnim.egg'})
     self.fish4.loop('swimming')
     self.fish4.reparentTo(self.enviroNode)
     self.fish4Tex = loader.loadTexture("Textures/red.tif")
     self.fish4.setTexture(self.fish4Tex, 1)
     self.fish4.setScale(.8)
     self.fish4.setPos(55, -70, 135)
     ## self.fish4.place()
     # Sequence for fish4 Movement
     self.fish4PosInterval1 = self.fish4.posInterval(10,Point3(55, -70, 135),startPos=Point3(75, -30, 135))
     self.fish4PosInterval2 = self.fish4.posInterval(10,Point3(75, -30, 135),startPos=Point3(55, -70, 135))
     self.fish4HprInterval1 = self.fish4.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))
     self.fish4HprInterval2 = self.fish4.hprInterval(3,Point3(0, 0, 0),startHpr=Point3(180, 0, 0))
     self.fish4move = Sequence(self.fish4PosInterval2, self.fish4HprInterval1, self.fish4PosInterval1, self.fish4HprInterval2, name="fish4move")        
     self.fish4move.loop()
     
     
     #Load Shrimp
     self.fish5 = loader.loadModel("Models/cleanerShrimpModel.egg")
     self.fish5 = Actor('Models/cleanerShrimpModel.egg', {'swimming':'Models/cleanerShrimpAnim.egg'})
     self.fish5.loop('swimming')
     self.fish5.reparentTo(self.enviroNode)
     ## self.fish5Tex = loader.loadTexture("Textures/red.tif")
     ## self.fish5.setTexture(self.fish5Tex, 1)
     self.fish5.setScale(.5)
     self.fish5.setPos(-230, -140, 4)
     ## self.fish5.setHpr(0, 0, 0)
     # Sequence for shrimp Movement
     self.fish5PosInterval1 = self.fish5.posInterval(10,Point3(-230, -140, 4),startPos=Point3(200, -140, 4))
     self.fish5PosInterval2 = self.fish5.posInterval(10,Point3(200, -140, 4),startPos=Point3(-230, -140, 4))
     self.fish5HprInterval1 = self.fish5.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))
     self.fish5HprInterval2 = self.fish5.hprInterval(3,Point3(0, 0, 0),startHpr=Point3(-180, 0, 0))
     self.fish5move = Sequence(self.fish5PosInterval2, self.fish5HprInterval1, self.fish5PosInterval1, self.fish4HprInterval2, name="fish5move")        
     self.fish5move.loop()
     
     #Load Seahorse
     self.fish6 = loader.loadModel("Models/seaHorseModel.egg")
     self.fish6 = Actor('Models/seaHorseModel.egg', {'floating':'Models/seaHorseAnim.egg'})
     self.fish6.loop('floating')
     self.fish6.reparentTo(self.enviroNode)
     self.fish6.setScale(.9)
     self.fish6.setPos(282,160,58)
     self.fish6.setHpr(90, 0, 0)
     ## self.fish6.place()
     
     # Loading in the first Toy Model
     self.toy1 = loader.loadModel("Models/car1.egg")
     self.toy1.reparentTo(self.enviroNode)
     ## self.toy1Tex = loader.loadTexture("Textures/car1_unwrap.png")
     ## self.toy1.setTexture(self.toy1Tex, 1)
     self.toy1.setScale(.5)
     self.toy1.setPos(-286.7, -73.5,12)
     self.toy1.setHpr(90, 0, 0)
     ## self.toy1.place()
     
#.........这里部分代码省略.........
开发者ID:mitchellvitez,项目名称:Bubble-Bonanza,代码行数:103,代码来源:fish_tank_final_computerVersion.py

示例9: Lvl03

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

#.........这里部分代码省略.........

        
        #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()
        self.background = OnscreenImage(image = 'models/gamedev/moltenbg.JPG', pos = (98,10,0),scale=500)
        self.background.reparentTo(render)
        
        self.lava = loader.loadModel("models/gamedev/lava")
        self.lava.setPosHpr(Vec3(98,0,-18),Vec3(0,5,0))
        self.lava.setScale(50)
        self.lava.reparentTo(render)
        
        
        x1= 196
        x2 = 0
        m1 = 98
        m2 = 107.8
        len = 9.8
        h = 0
        a = 0
        p = 0
        
        for j in range(4):
            if j > 0:
                x1Old = x1
                x2Old = x2
                x1 = 196-(random.randint(0,3)*9.8)
                x2 = 0+random.randint(0,3)*9.8
                m1=98-(random.randint(0,3)*9.8)
                m2= 107.8+random.randint(0,3)*9.8
            
                for count in range(1):
                    l = random.randint(2,5)
                    r = random.randint(2,5)
                    c1 = random.randint(2,5)
                    c2 = random.randint(2,5)
                    if l+r < 4:
		        count = 0
			
            else:
                l = 4
                r = 4
开发者ID:CarlosPlusPlus,项目名称:rpi-undergrad,代码行数:70,代码来源:LVL03.py

示例10: World

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

#.........这里部分代码省略.........
        object.setLight(self.fillLightNP)
        object.setLight(self.boosterLightNP)
        for light in self.flameLights:
            object.setLight(light[1])
        
    def shiftCamera(self):
        if self.cameraMove:
            self.cameraMove.finish()
        old = self.cameraIndex
        self.cameraIndex += 1
        if self.cameraIndex == len(self.cameraPositions):
            self.cameraIndex = 0
        self.cameraMove=LerpPosHprInterval(camera,
                                            .7, 
                                            self.cameraPositions[self.cameraIndex][0], 
                                            self.cameraPositions[self.cameraIndex][1],
                                            camera.getPos(), 
                                            camera.getHpr())
        self.cameraMove.start()
     
    def loadModels(self):
        """loads models into the world"""
        #eat no longer exists? Phooey
        
        self.flameLights = []
        shadowcam = Spotlight('shadowlight')
        shadowcam.setColor(VBase4(0,0,0,1))
        lens = PerspectiveLens()
        shadowcam.setLens(lens)
        shadowcam.setAttenuation(Point3(0, 0.001, 0.001))
        shadowNP = self.player.attachNewNode(shadowcam)
        shadowNP.setPos(0, -1400, 450)
        shadowNP.lookAt(self.player)
        shadowNP.setScale(200)
        shadowNP.node().setShadowCaster(True)
        self.flameLights.append((shadowcam, shadowNP))
        
        for i in range(2):
            slight = PointLight('plight')
            slight.setColor(VBase4(0, 0, 0, 1))
            slight.setAttenuation(Point3(0, 0.001, 0.001))
            slnp = self.player.attachNewNode(slight)
            slnp.setPos(0, -750 - (950 * i), 450)
            slnp.setHpr(180, 0, 0)
            slnp.setScale(200)
            self.flameLights.append((slight, slnp))
        
        self.player.setupBooster()
        
        #self.env = loader.loadModel("models/environment")
        #self.env.reparentTo(render)
        #self.env.setScale(.25)
        #self.env.setPos(-8, 42, 0)
        self.env = loader.loadModel("models/terrain2")      
        self.env.reparentTo(render)
        self.env.setPos(0,0,0)
        
        self.setWorldLight(self.env)
        
        #load targets
        self.targets = []
        for i in range (10):
            target = loader.loadModel("smiley")
            target.setScale(.5)
            target.setPos(random.uniform(-20, 20), random.uniform(-15, 15), 2)
            target.reparentTo(self.targetRoot)
开发者ID:Splime,项目名称:ProjectThree,代码行数:70,代码来源:tutorial8.py

示例11: __init__

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class PipeGeneric:
    """
    Creates self contained pipe objects with methods that create,
    reference, and destroy models, collision tubes, lights,
    particles, and ActionCommand sequences.
    """
    def __init__(self, bag, template=False):

        if template is not False: self.reactivate(template)
        else:
            self.addModel(bag)
            self.addPointLight(self.model)
            self.shaderEnabled = 0
            #self.addCollision()
            #self.addParticle()
            self.addActionCommand("")
            self.type = "generic"

    def addPointLight(self, pipe):
        """create a point light for pipe"""

        #The redpoint light and helper
        #RED
        # r = random.uniform(700, 900) / 1000
        # g = random.uniform(0, 300) / 1000
        # b = g

        #ORANGE
        r = 1
        b = random.randint(0,91)
        g = (b / 2) + 102
        b = b / 255.0
        g = g / 255.0
        self.helper = loader.loadModel("../models/sphere.egg.pz")

        self.helper.setColor( Vec4( r, g, b, 1 ) )
        self.helper.setPos(pipe.getPos())
        #print self.helper.getColor()

        #This is value is irrelevent at the moment unless I move the lights
        self.helper.setScale(.25*1) #must be greater than 0.001


        #optionally set location of light within pipe
        self.helper.setY(self.helper.getY()-50*35 ) #moves to inbetween segments
        self.helper.setZ(self.helper.getZ()-50*6 ) #makes 3 sided lights

        self.light = self.helper.attachNewNode( PointLight( "self.light" ) )
        self.light.node().setAttenuation( Vec3( .1, 0.04, 0.1 )/2.5 )
        self.light.node().setColor( Vec4( r, g, b, 1 ) )
        self.light.node().setSpecularColor( Vec4( 1 ) )
        self.helper.reparentTo( pipe )
        render.setLight( self.light )


    def addModel(self, bag):
        """Adds the model to the pipe object"""

        #pick file
        filename = ["../models/tunnel"]
        filename.append(str(bag.pick()))
        filename.append(".egg")
        self.fileName = ''.join(filename)

        #self.fileName = "../models/tunnelclear.egg"

        #load model
        self.model = loader.loadModel(self.fileName)
        self.model.setScale(.0175)
        #print self.model.ls()

        #rotate by 0, 90, 180, or 270 degrees
        self.model.setR(random.randint(0,3)*90)
        #print self.model.getR()

        self.nodePath = NodePath(self.model)
        self.model.reparentTo(render)
        self.key = self.model.getKey()

    def addShader(self):
        self.model.setShaderAuto()
        self.shaderEnabled = 1


    def addCollision(self):
        #Finding and adding collision tube to the pipe
        #cSphere = CollisionSphere((200,0,0), 100)
        cNode = self.nodePath.find("**/tube_collision").node()
        #cNode = CollisionNode("pipeCollision")
        #cNode.addSolid(solid)
        self.collision = self.model.attachNewNode(cNode)
        self.collision.show()


    def addParticle(self, pipe):
        #Particle Effect: VERY SLOW
        self.particle = ParticleEffect()
        self.particle.loadConfig("../models/steam.ptf")
        self.particle.start(pipe)
        self.particle.setPos(100.00, 0.000, 0)
#.........这里部分代码省略.........
开发者ID:kridily,项目名称:fall_and_fix,代码行数:103,代码来源:PipeGeneric.py

示例12: World

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

#.........这里部分代码省略.........
        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
            self.gasLossTime = task.time
            # print self.player.totalGas
        return Task.cont
           
    def mouseTask(self, task):
        j = -1
开发者ID:Splime,项目名称:ProjectThree,代码行数:70,代码来源:world.py

示例13: Player

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import setScale [as 别名]
class Player(DirectObject):
    def __init__(self, dogSelection):
        self.playing_dead = False
        self._keymap = {
                'forward' : 0,
                'reverse' : 0,
                'right'   : 0,
                'left'    : 0,
                'jump'    : 0,
                'bark'    : 0,
        }
        self._dir = 0
        self.dogSelection = dogSelection
        if self.dogSelection == 2:
            self._coll_dist = 4
            self._coll_dist_h = 1.5
        else:
            self._coll_dist = 6
            self._coll_dist_h = 3
        self._scale = .5 * settings.GLOBAL_SCALE
        self._load_models()
        self._load_sounds()
        self._load_lights()
        self._setup_actions()
        self._setup_tasks()
        self._setup_collisions()
        self.bag = None
        self.gravity = 0
        self.jumping = 15
        self.falling = 0
        self.package = False
        self.jumpingCurrently = False
        self.chase = False
        self.chasetimer = settings.PLAYER_CHASE_LENGTH
        self.inst1 = addInstructions(0.95, str(self._model.getPos()))
        self.blocks = []
        self.currentRoom = 1
        self.lose = False
        
        self.win = False
    def _load_models(self):
        if self.dogSelection == 2:
            self._model = Actor("models/sdog.egg", {"walking":"models/sdoganim.egg"})
            #self._model2 = Actor("models/sdogb.egg", {"walking":"models/sdoganimb.egg"})
        else:
            self._model = Actor("models/bdog", {"walking":"models/bdoganim.egg"})
            #self._model2 = Actor("models/bdogb", {"walking":"models/bdoganimb.egg"})
        self.animControl =self._model.getAnimControl('walking')
        self.currentFrame = self.animControl.getFrame()
        self._model.reparentTo(render)
        self._model.setScale(.5 * settings.GLOBAL_SCALE)
        self._model.setPos(550, 0, 5)
        self._model.setH(-90)
        self.p = ParticleEffect()

    def _load_sounds(self):
        self.sound_bark = loader.loadSfx(os.path.join("sound files", "Dog Barking.mp3"))
        self.sound_dog_footsteps = loader.loadSfx(os.path.join("sound files", "Dog Footsteps.mp3"))

    def _load_lights(self):
        pass

    def _setup_actions(self):
        """
        self.accept("arrow_up", self._set_key, ["reverse", 1])
        self.accept("arrow_up-up", self._set_key, ["reverse", 0])
        self.accept("arrow_down", self._set_key, ["forward", 1])
        self.accept("arrow_down-up", self._set_key, ["forward", 0])
        self.accept("arrow_left", self._set_key, ["left", 1])
        self.accept("arrow_left-up", self._set_key, ["left", 0])
        self.accept("arrow_right", self._set_key, ["right", 1])
        self.accept("arrow_right-up", self._set_key, ["right", 0])
        """
        self.accept("w", self._set_key, ["reverse", 1])
        self.accept("w-up", self._set_key, ["reverse", 0])
        self.accept("s", self._set_key, ["forward", 1])
        self.accept("s-up", self._set_key, ["forward", 0])
        self.accept("a", self._set_key, ["left", 1])
        self.accept("a-up", self._set_key, ["left", 0])
        self.accept("d", self._set_key, ["right", 1])
        self.accept("d-up", self._set_key, ["right", 0])
        self.accept("e", self._set_key, ["bark", 1])
        self.accept('space',self._set_key, ["jump", 1])
        self.accept('space-up', self._set_key, ["jump", 0])
        self.accept('f', self.play_dead)

    def _setup_tasks(self):
        self._prev_move_time = 0
        taskMgr.add(self._task_move, "player-task-move")
        taskMgr.add(self._update_camera, "update-camera")

    def _setup_collisions(self):
        self._coll_trav = CollisionTraverser()
        # Front collision
        self._gnd_handler_front = CollisionHandlerQueue()
        self._gnd_ray_front = CollisionRay()
        self._gnd_ray_front.setOrigin(0, self._coll_dist, 1)
        self._gnd_ray_front.setDirection(0, 0, -1)
        self._gnd_coll_front = CollisionNode('collision-ground-front')
        self._gnd_coll_front.addSolid(self._gnd_ray_front)
#.........这里部分代码省略.........
开发者ID:MrSuborbian88,项目名称:perfumedprotector,代码行数:103,代码来源:player.py


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