本文整理汇总了Python中vehicle.Vehicle.getPos方法的典型用法代码示例。如果您正苦于以下问题:Python Vehicle.getPos方法的具体用法?Python Vehicle.getPos怎么用?Python Vehicle.getPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vehicle.Vehicle
的用法示例。
在下文中一共展示了Vehicle.getPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from vehicle import Vehicle [as 别名]
# 或者: from vehicle.Vehicle import getPos [as 别名]
#.........这里部分代码省略.........
self.staticRoot = render.attachNewNode('staticRoot')
self.mouseTask = taskMgr.add(self.mouseTask, 'mouseTask')
def dfs(self, item = render, depth = 0, file = None):
if file:
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):