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


Python Vector.y方法代码示例

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


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

示例1: rule3

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import y [as 别名]
 def rule3(self, hoik):
     v = Vector(0, 0)
     if hoik.pos.x < 10:
         v.x = 20
     elif hoik.pos.x > C.SCREEN_SIZE.x-10:
         v.x = -20
     if hoik.pos.y < 10:
         v.y = 20
     elif hoik.pos.y > C.SCREEN_SIZE.y-10:
         v.y = -20
     return v
开发者ID:EinarKristoffersen,项目名称:Python,代码行数:13,代码来源:Hoik.py

示例2: rule7

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import y [as 别名]
 def rule7(self, this_boid):
     v = Vector(0, 0)
     if this_boid.pos.x < 10:
         v.x = 20
     elif this_boid.pos.x > C.SCREEN_SIZE.x-10:
         v.x = -20
     if this_boid.pos.y < 10:
         v.y = 20
     elif this_boid.pos.y > C.SCREEN_SIZE.y-10:
         v.y = -20
     return v
开发者ID:EinarKristoffersen,项目名称:Python,代码行数:13,代码来源:Boid.py

示例3: test_Vector_attribute_setting_should_work

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import y [as 别名]
def test_Vector_attribute_setting_should_work(x,y, new_x,new_y):
    v = Vector(x,y)
    v.x = new_x
    assert v.x == new_x
    assert v.y == y
    v.y = new_y
    assert v.y == new_y
    assert v.x == new_x
开发者ID:carlosghabrous,项目名称:ghabcode,代码行数:10,代码来源:Vector_test.py

示例4: collisionDetector

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import y [as 别名]
    def collisionDetector(self):
        dynamic_length = self.v.mod()/self.max_v*self.max_see_ahead
        ahead = self.p + self.v.norm(dynamic_length)
        ahead2 = self.p + self.v.norm(dynamic_length*0.5)
        obstacle = self.takeOver(ahead, ahead2)
        avoidance = Vector()
 
        if (obstacle.p.coord() != [-1, -1]):
            avoidance = ahead-obstacle.p
            if (avoidance.x() == 0):
                avoidance = Vector([self.max_avoid_force, 0])
            elif (avoidance.y() == 0):
                avoidance = Vector([0, self.max_avoid_force])

        return avoidance
开发者ID:matteosan1,项目名称:python_code,代码行数:17,代码来源:steering2.py

示例5: player_destination

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import y [as 别名]
      def player_destination(self):
            """Function that plots the player destination on the screen.

            player destination set by setting a blank vector and altering the x and y
            coords based on which key is pressed by the user. The player destination will
            then consist of a heading, and multiple key presses will simulate movement.

            pressed_keys: holds the state of all keyboard buttons. Used to determine
            if the user has pressed any of the buttons designed for movement.
          
            heading: holds a vector that corresponds to a heading. Determined by
            key presses.
            """
            # Select a point on the screen
            # set up variable to hold the result of determining if a key is pressed
            pressed_keys = pygame.key.get_pressed()
            heading = Vector(0,0)

            if pressed_keys[K_LEFT]:
                  heading.x = -1
            elif pressed_keys[K_RIGHT]:
                  heading.x = +1
            elif pressed_keys[K_UP]:
                  heading.y = -1
            elif pressed_keys[K_DOWN]:
                  heading.y = +1

            #diagonals
            if pressed_keys[K_RIGHT] and pressed_keys[K_UP]:
                  heading.x = 0.707
                  heading.y = -0.707
            if pressed_keys[K_DOWN] and pressed_keys[K_RIGHT]:
                  heading.x = 0.707
                  heading.y = 0.707
            if pressed_keys[K_DOWN] and pressed_keys[K_LEFT]:
                  heading.x = -0.707
                  heading.y = 0.707
            if pressed_keys[K_UP] and pressed_keys[K_LEFT]:
                  heading.x = -0.707
                  heading.y = -0.707

            self.heading = heading

            self.destination = self.location
开发者ID:Mecharyry,项目名称:PythonGame,代码行数:46,代码来源:Entities.py


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