本文整理匯總了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):