本文整理汇总了Python中vehicle.Vehicle.getX方法的典型用法代码示例。如果您正苦于以下问题:Python Vehicle.getX方法的具体用法?Python Vehicle.getX怎么用?Python Vehicle.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vehicle.Vehicle
的用法示例。
在下文中一共展示了Vehicle.getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from vehicle import Vehicle [as 别名]
# 或者: from vehicle.Vehicle import getX [as 别名]
class World(DirectObject):
def __init__(self):
#turn off mouse control, otherwise camera is not repositionable
self.lightables = []
self.cameraPositions = [((0, 5000, 5300), (180, -35, 0)),((0, 3000, 1300), (180, -15, 0))]
self.cameraIndex = 0
base.disableMouse()
base.enableParticles()
self.setupLights()
self.setupPicking()
#Prepare the vehicular manslaughter!
self.boosterLightNP = None
self.flameLights = None
self.player = Vehicle("models/panda-model", "panda-walk4", self)
self.loadModels()
# self.player.setPos(self.env.find("**/start_point").getPos())
self.player.setPos(0,0,0)
self.setupIntervals()
camera.reparentTo(self.player)
camera.setPosHpr(0, 5000, 5300, 180, -35, 0)
self.setupCollisions()
render.setShaderAuto() #you probably want to use this
self.keyMap = {"left":0, "right":0, "forward":0, "backwards":0}
taskMgr.add(self.player.move, "moveTask")
#Give the vehicle direct access to the keyMap
self.player.addKeyMap(self.keyMap)
self.prevtime = 0
self.isMoving = False
self.speed_norm = 8
self.speed = self.speed_norm
self.accept("escape", sys.exit)
self.accept("arrow_up", self.setKey, ["forward", 1])
self.accept("w", self.setKey, ["forward", 1])
self.accept("arrow_right", self.setKey, ["right", 1])
self.accept("d", self.setKey, ["right", 1])
self.accept("arrow_left", self.setKey, ["left", 1])
self.accept("a", self.setKey, ["left", 1])
self.accept("arrow_down", self.setKey, ["backwards", 1])
self.accept("s", self.setKey, ["backwards", 1])
self.accept("arrow_up-up", self.setKey, ["forward", 0])
self.accept("w-up", self.setKey, ["forward", 0])
self.accept("arrow_right-up", self.setKey, ["right", 0])
self.accept("d-up", self.setKey, ["right", 0])
self.accept("arrow_left-up", self.setKey, ["left", 0])
self.accept("a-up", self.setKey, ["left", 0])
self.accept("arrow_down-up", self.setKey, ["backwards", 0])
self.accept("s-up", self.setKey, ["backwards", 0])
self.accept("mouse1", self.startShoot)
self.accept("mouse1-up", self.stopShoot)
self.accept("tab", self.shiftCamera)
self.accept("space", self.player.startBoosters)
self.accept("ate-smiley", self.eat)
self.accept("ground_collide", self.player.collider)
self.p1 = ParticleEffect()
self.p2 = ParticleEffect()
#Show collisiony stuff
base.cTrav.showCollisions(render)
def setupPicking(self):
self.picker = CollisionTraverser()
self.pq = CollisionHandlerQueue()
self.pickerNode = CollisionNode('mouseRay')
self.pickerNP = camera.attachNewNode(self.pickerNode)
self.pickerNode.setFromCollideMask(BitMask32.bit(1))
self.pickerRay = CollisionRay()
self.pickerNode.addSolid(self.pickerRay)
self.picker.addCollider(self.pickerNP, self.pq)
self.targetRoot = render.attachNewNode('targetRoot')
self.mouseTask = taskMgr.add(self.mouseTask, 'mouseTask')
def mouseTask(self, task):
if base.mouseWatcherNode.hasMouse():
mpos = base.mouseWatcherNode.getMouse()
self.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
self.picker.traverse(self.targetRoot)
if self.pq.getNumEntries() > 0:
self.pq.sortEntries()
i = int(self.pq.getEntry(0).getIntoNode().getTag('target'))
print("Found target: " + str(i))
return Task.cont
def setupIntervals(self):
self.lightOn = LerpFunc(self.lightModify,
fromData=0,
toData=100,
duration=0.2,
blendType='noBlend',
extraArgs=[True],
name="LightUp")
#.........这里部分代码省略.........