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


Python Ball.position方法代码示例

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


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

示例1: World

# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import position [as 别名]

#.........这里部分代码省略.........
        # Set up the camera

        base.disableMouse()
        base.camera.setPos(self.player.getX(),self.player.getY()+10,2)

        # Create some lighting

        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.3, .3, .3, 1))
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3(-5, -5, -5))
        directionalLight.setColor(Vec4(1, 1, 1, 1))
        directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
        render.setLight(render.attachNewNode(ambientLight))
        render.setLight(render.attachNewNode(directionalLight))

    #Records the state of the arrow keys
    def setKey(self, key, value):
        self.keyMap[key] = value

    # Character name needs to be: car, ralph or panda
    def loadCharacter(self, name):
        if name == 'ralph':
            return Ralph(render, (30, 30, 0)).actor
        elif name == 'car':
            return Car(render, (10, 10, 0)).model
        elif name == 'panda':
            return Panda(render, (20, 20, 0)).actor
    # Accepts arrow keys to move either the player or the menu cursor,
    # Also deals with grid checking and collision detection

    def checkCollision(self):

        if ((self.player.getPos() - self.ball1.position()).length() < 0.5):
            self.canMove=False

        elif (self.player.getPos() - self.ball2.position()).length() < 1.0:
            self.canMove=False

        elif (self.player.getPos() - self.ball3.position()).length() < 1.6:
            self.canMove=False

        # elif (self.player.getPos() - self.car.position()).length() < 1.6:
        #     self.canMove=False

        # elif (self.player.getPos() - self.panda1.position()).length() < 1.6:
        #     self.canMove=False
        #
        # elif (self.player.getPos() - self.panda2.position()).length() < 1.6:
        #     self.canMove=False

        else:
            self.canMove=True

        return not self.canMove

    def move(self, task):

        # If the camera-left key is pressed, move camera left.
        # If the camera-right key is pressed, move camera right.

        base.camera.lookAt(self.player)
        if (self.keyMap["cam-left"]!=0):
            base.camera.setX(base.camera, -20 * globalClock.getDt())
        if (self.keyMap["cam-right"]!=0):
            base.camera.setX(base.camera, +20 * globalClock.getDt())
开发者ID:jaimeh,项目名称:hw2-cs454,代码行数:70,代码来源:game.py


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