本文整理汇总了Python中direct.particles.ParticleEffect.ParticleEffect.softStop方法的典型用法代码示例。如果您正苦于以下问题:Python ParticleEffect.softStop方法的具体用法?Python ParticleEffect.softStop怎么用?Python ParticleEffect.softStop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.particles.ParticleEffect.ParticleEffect
的用法示例。
在下文中一共展示了ParticleEffect.softStop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BlockDestroyedEffect
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [as 别名]
class BlockDestroyedEffect(object):
__base = None
__pos = None
def __init__(self, base, pos):
self.__base = base
self.__pos = pos
self.particleEffect()
def particleEffect(self):
self.p = ParticleEffect()
self.loadParticleConfig('particleEffect.ptf')
self.__base.taskMgr.doMethodLater(0.5, self.stopParticles, "stop")
self.__base.taskMgr.doMethodLater(2.0, self.cleanUpParticles, "cleanup")
def cleanUpParticles(self, task):
self.p.cleanup()
def stopParticles(self, task):
self.p.softStop()
def loadParticleConfig(self, file):
self.p.cleanup()
self.p = ParticleEffect()
self.p.loadConfig(Filename(file))
self.p.setPos(self.__pos.x, self.__pos.y, 2)
self.p.start(parent = self.__base.render, renderParent = self.__base.render)
示例2: _make_pfx
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [as 别名]
def _make_pfx (self, enode, rnode, pos, radius, scale1, scale2,
birthrate, lifespan, zspinini, zspinfin, zspinvel,
poolsize, littersize, amplitude, ampspread, risefact,
texpath, color, alphamode, softstop):
pfx = ParticleEffect()
pfx.setPos(pos)
p0 = make_particles()
p0.setPoolSize(poolsize)
p0.setBirthRate(birthrate)
p0.setLitterSize(littersize)
p0.setLitterSpread(0)
#p0.setSystemLifespan(1.0)
#p0.setLocalVelocityFlag(1)
#p0.setSystemGrowsOlderFlag(0)
# p0.setFactory("PointParticleFactory")
# p0.factory.setLifespanBase(lifespan)
# p0.factory.setLifespanSpread(0.0)
# #p0.factory.setMassBase(1.00)
# #p0.factory.setMassSpread(0.00)
# #p0.factory.setTerminalVelocityBase(400.0000)
# #p0.factory.setTerminalVelocitySpread(0.0000)
p0.setFactory("ZSpinParticleFactory")
p0.factory.setLifespanBase(lifespan)
p0.factory.setLifespanSpread(0.0)
#p0.factory.setMassBase(1.00)
#p0.factory.setMassSpread(0.00)
#p0.factory.setTerminalVelocityBase(400.0000)
#p0.factory.setTerminalVelocitySpread(0.0000)
p0.factory.setAngularVelocity(zspinvel)
p0.factory.setFinalAngle(zspinfin)
p0.factory.setInitialAngle(zspinini)
p0.setRenderer("SpriteParticleRenderer")
p0.renderer.setAlphaMode(alphamode)
texpaths = texpath
if not isinstance(texpath, (tuple, list)):
texpaths = [texpaths]
for texpath in texpaths:
texture = base.load_texture("data", texpath)
p0.renderer.addTexture(texture)
# p0.renderer.setUserAlpha(alpha)
p0.renderer.setColor(color)
p0.renderer.setXScaleFlag(1)
p0.renderer.setYScaleFlag(1)
p0.renderer.setAnimAngleFlag(1)
p0.renderer.setInitialXScale(scale1)
p0.renderer.setFinalXScale(scale2)
p0.renderer.setInitialYScale(scale1)
p0.renderer.setFinalYScale(scale2)
p0.setEmitter("SphereVolumeEmitter")
p0.emitter.setRadius(radius)
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(amplitude)
p0.emitter.setAmplitudeSpread(ampspread)
#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))
f0 = ForceGroup("vertex")
force0 = LinearVectorForce(risefact * amplitude)
force0.setActive(1)
f0.addForce(force0)
p0.setRenderParent(rnode)
pfx.addForceGroup(f0)
pfx.addParticles(p0)
pfx.start(enode)
if softstop:
pfx.softStop()
return pfx
示例3: Vehicle
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [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
示例4: Vehicle
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [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
示例5: World
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [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()
示例6: World
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [as 别名]
#.........这里部分代码省略.........
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():
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') != "":
j = int(self.pq.getEntry(i).getIntoNode().getTag('car'))
carpos = self.staticCars[j].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[j] > 0 and dist < DRAIN_DIST:
示例7: Demo
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [as 别名]
class Demo(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.title = OnscreenText(
text = "Panda3D : Tutorial - Particles",
parent = self.a2dBottomCenter,
style = 1,
fg = (1, 1, 1, 1),
pos = (0.06, -0.06),
align = TextNode.ALeft,
scale = 0.05
)
self.accept("escape", sys.exit)
self.accept("1", self.loadParticleConfig, ["steam.ptf"])
self.accept("2", self.loadParticleConfig, ["dust.ptf"])
self.accept("3", self.loadParticleConfig, ["fountain.ptf"])
self.accept("4", self.loadParticleConfig, ["smoke.ptf"])
self.accept("5", self.loadParticleConfig, ["smokering.ptf"])
self.accept("6", self.loadParticleConfig, ["fireish.ptf"])
self.disableMouse()
self.cam.setPos(0, -20, 2)
self.camLens.setFov(25)
self.setBackgroundColor(0, 1, 0)
self.enableParticles()
self.teapot = self.loader.loadModel("teapot")
self.teapot.setPos(0, 10, 0)
self.teapot.reparentTo(self.render)
self.setupLights()
self.particle = ParticleEffect()
self.loadParticleConfig("steam.ptf")
self.accept("w", self.toggle_particle)
def toggle_particle(self):
particleSeq = Sequence(Func(self.particle_start),
Wait(2),
Func(self.particle_end))
particleSeq.start()
def loadParticleConfig(self, filename):
self.particle.cleanup()
self.particle = ParticleEffect()
self.particle.loadConfig("/e/Panda3D-1.9.2-x64/samples/particles/"+filename)
#self.particle.start(self.teapot)
self.particle.setPos(3, 0, 2.225)
def particle_start(self):
self.particle.start(self.teapot)
def particle_end(self):
self.particle.softStop()
def setupLights(self):
ambientLight = AmbientLight("ambiengtLight")
ambientLight.setColor((0.4, 0.4, 0.35, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(LVector3(0, 8, -2.5))
directionalLight.setColor((0.9, 0.8, 0.9, 1))
directionalLight.setColor((0.9, 0.8, 0.9, 1))
self.teapot.setLight(self.teapot.attachNewNode(directionalLight))
self.teapot.setLight(self.teapot.attachNewNode(ambientLight))
示例8: Player
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import softStop [as 别名]
#.........这里部分代码省略.........
self.jumping=15
self.falling=0
if self.gravity == 1 and not self.jumpingCurrently:
pos_z+=self.fall()
self._model.setZ(pos_z)
else:
if len(entries_front) > 0 and entries_front[0].getSurfacePoint(render).getZ()>self._model.getZ():
self._model.setZ(entries_front[0].getSurfacePoint(render).getZ())
self.gravity=0
self.jumpingCurrently=False
self.jumping=15
self.falling=0
if self.gravity == 1 and not self.jumpingCurrently:
pos_z+=self.fall()
self._model.setZ(pos_z)
#elif self.is_valid(entries_front) and self.is_valid(entries_back) and self.is_valid(entries_left) and self.is_valid(entries_right) and self.is_valid(entries_front_right) and self.is_valid(entries_front_left) and self.is_valid(entries_back_left) and self.is_valid(entries_back_right):
elif self.is_valid(entries_wall):
if len(entries_front) > 0 and len(entries_back) > 0:
f = entries_front[0].getSurfacePoint(render).getZ()
b = entries_back[0].getSurfacePoint(render).getZ()
#l = entries_left[0].getSurfacePoint(render).getZ()
#r = entries_right[0].getSurfacePoint(render).getZ()
z = (f + b) / 2
if abs(z - self._model.getZ()) > 5:
self.gravity=1
else:
#self._model.setZ(z)
#self._model.setP(rad2Deg(math.atan2(f - z, self._coll_dist * self._scale)))
#self._model.setR(rad2Deg(math.atan2(l - z, self._coll_dist_h * self._scale)))
pass
else:
self._model.setPos(pos)
if not self.chase and self.chasetimer < settings.PLAYER_CHASE_LENGTH:
self.chasetimer += 1
self._prev_move_time = task.time
self.inst1.destroy()
self.inst1 = addInstructions(0.95, str(self._model.getPos()))
return Task.cont
def is_valid(self, entries):
#if len(entries) == 0:
#return False
for x in entries:
if x.getIntoNode().getName()!='ground1':
return False
return True
def jump(self):
if self.jumping>0:
self.gravity=1
self.jumping-=.5
return self.jumping*.5
else:
return self.fall()
def fall(self):
self.falling-=.5
return self.falling*.5
def loadParticleConfig(self, position):
self.p.cleanup()
self.p = ParticleEffect()
self.p.loadConfig(os.path.join("models", "smokering.ptf"))
self.p.accelerate(.25)
self.p.setPos(position)
self.p.reparentTo(render)
self.p.setScale(30)
self.p.start()
#taskMgr.doMethodLater(5, self.cleanParticles, 'Stop Particles')
def cleanParticles(self, random):
self.p.softStop()
def play_dead(self):
self.playing_dead = not self.playing_dead
if self.playing_dead:
self._model.setR(self._model.getR()+10)
self._model.setZ(self._model.getZ()+1)
else:
self._model.setR(self._model.getR()-10)
self._model.setZ(self._model.getZ()-1)
def passBlocks(self, blocks):
self.blocks = blocks
def passCurrentRoom(self, currentRoom):
self.currentRoom = currentRoom
def game_over(self):
self.lose = True
taskMgr.doMethodLater(3, sys.exit, "game_over")
if self.dogSelection == 2: #small
self.a = OnscreenImage(parent=render2d, image=os.path.join("image files", "Game-Over-Screen-Small.png"))
else:
self.a = OnscreenImage(parent=render2d, image=os.path.join("image files", "Game-Over-Screen-Big.png"))