本文整理汇总了Python中pygame.Rect.unionall_ip方法的典型用法代码示例。如果您正苦于以下问题:Python Rect.unionall_ip方法的具体用法?Python Rect.unionall_ip怎么用?Python Rect.unionall_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.Rect
的用法示例。
在下文中一共展示了Rect.unionall_ip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unionall_ip
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall_ip [as 别名]
def test_unionall_ip( self ):
r1 = Rect( 0, 0, 1, 1 )
r2 = Rect( -2, -2, 1, 1 )
r3 = Rect( 2, 2, 1, 1 )
r1.unionall_ip( [r2,r3] )
self.assertEqual( Rect(-2, -2, 5, 5), r1 )
示例2: set_screen_background
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall_ip [as 别名]
def set_screen_background(self):
""" Update the background """
logger.log( 9, 'set_screen_background()')
if not self.background:
self.background = osd.get_singleton().getsurface(rect=self.rect)
self.updates = []
elif len(self.updates) > 0:
# find the topleft corner
x = self.rect.right
y = self.rect.bottom
for i in self.updates:
x = min(x, i.left)
y = min(y, i.top)
# find the total rect of the collisions
upd = Rect(x, y, 0, 0)
upd.unionall_ip(self.updates)
self.updates = []
x = upd[0] - self.rect.left
y = upd[1] - self.rect.top
bg_tmp = osd.get_singleton().getsurface(rect=upd)
self.background.blit(bg_tmp, (x, y))
self.surface.blit(self.background, (0,0))
示例3: test_unionall_ip
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall_ip [as 别名]
def test_unionall_ip( self ):
r1 = Rect( 0, 0, 1, 1 )
r2 = Rect( -2, -2, 1, 1 )
r3 = Rect( 2, 2, 1, 1 )
r1.unionall_ip( [r2,r3] )
self.assertEqual( Rect(-2, -2, 5, 5), r1 )
# Bug for an empty list. Would return a Rect instead of None.
self.assertTrue(r1.unionall_ip( [] ) is None)