當前位置: 首頁>>代碼示例>>Python>>正文


Python Polygon.createBoundingBoxPolygon方法代碼示例

本文整理匯總了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        
開發者ID:ducino,項目名稱:dig,代碼行數:10,代碼來源:Actor.py

示例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
開發者ID:ducino,項目名稱:dig,代碼行數:26,代碼來源:Test.py

示例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)
開發者ID:ducino,項目名稱:dig,代碼行數:33,代碼來源:Test.py


注:本文中的Polygon.Polygon.createBoundingBoxPolygon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。