本文整理汇总了Python中Polygon.Polygon.createBoundingBoxPolygon方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.createBoundingBoxPolygon方法的具体用法?Python Polygon.createBoundingBoxPolygon怎么用?Python Polygon.createBoundingBoxPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.createBoundingBoxPolygon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateLocation
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import createBoundingBoxPolygon [as 别名]
def updateLocation(self, newLocation):
self.previousLocation = self.location
self.location = newLocation
self.bbox = BoundingBox(self.location.x-self.width/2, self.location.y-self.height/2,
self.location.x+self.width/2, self.location.y+self.height/2)
self.polygon = Polygon.createBoundingBoxPolygon(Vector(self.location.x-self.width/2, self.location.y-self.height/2),
Vector(self.location.x+self.width/2, self.location.y+self.height/2))
self.polygon.convex = True
示例2: on_key_press
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import createBoundingBoxPolygon [as 别名]
def on_key_press(symbol, modifiers):
global actor
if symbol == key.LEFT:
actor.controls.pressedLeft = True
if symbol == key.RIGHT:
actor.controls.pressedRight = True
if symbol == key.UP:
actor.controls.pressedUp = True
if symbol == key.DOWN:
actor.controls.pressedDown = True
if symbol == key.SPACE:
actor.controls.pressedJump = True
global polygon2
global debug
if symbol == key.A:
polygon2 = Polygon.createBoundingBoxPolygon(Vector(-20, -20), Vector(40, 0))
polygon2.midpointDisplacement(8)
polygon2.midpointDisplacement(6)
polygon2.triangulate()
if symbol == key.Z:
debug = (debug + 1)%4
示例3: Line
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import createBoundingBoxPolygon [as 别名]
dx = (self.x1 - self.x2)
hx = (self.x1 + self.x2)/2
hy = (self.y1 + self.y2)/2
return Line(hx, hy, hx - dy, hy + dx)
debug = 0
actor = Actor()
world = QuadNode()
# polygon = Polygon()
# polygon.addVertex(Vector(-100., -100.))
# polygon.addVertex(Vector(100., -100.+random.randrange(-10., 10.)))
# polygon.addVertex(Vector(50., 0.))
# world.add(polygon)
polygon = Polygon.createBoundingBoxPolygon(Vector(-100, -100), Vector(100, 0))
polygon.midpointDisplacement(10)
polygon.midpointDisplacement(10)
polygon.midpointDisplacement(8)
polygon.midpointDisplacement(6)
polygon.triangulate()
world.add(polygon)
polygon2 = Polygon.createBoundingBoxPolygon(Vector(-20, -20), Vector(40, 0))
polygon2.midpointDisplacement(8)
polygon2.midpointDisplacement(6)
polygon2.triangulate()
for i in range(-5, 5):
poly = Polygon.createBoundingBoxPolygon(Vector(-200*i, -200), Vector(-200*i+100+random.randrange(50, 150), -100))
poly.midpointDisplacement(10)