本文整理匯總了Python中surface.Surface.subsurface方法的典型用法代碼示例。如果您正苦於以下問題:Python Surface.subsurface方法的具體用法?Python Surface.subsurface怎麽用?Python Surface.subsurface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類surface.Surface
的用法示例。
在下文中一共展示了Surface.subsurface方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: from surface import Surface [as 別名]
# 或者: from surface.Surface import subsurface [as 別名]
def update(self):
self._heartLen = self._parent.getBaseHealth()
self.w, self.h = 10 * self._heartLen + 2 * ceil(self._heartLen / 2), 16
surf = Surface((self.w, self.h))
trans = self._heartFilled[0].get_at((0, 0))
surf.fill(trans)
surf.set_colorkey(trans)
self._display = Display(surface=surf, klass=self)
for i in range(self._heartLen):
self._hearts.append(surf.subsurface(Object(rect=(10 * i + 2 * (i // 2), 0, 10, 16)).asRect()))
示例2: __init__
# 需要導入模塊: from surface import Surface [as 別名]
# 或者: from surface.Surface import subsurface [as 別名]
def __init__(self, x, y, maxTime, numNums=3):
image, width = const.numbers
numbers = Files.loadImage(image)
numbers.set_colorkey(numbers.get_at((0, 0)))
super().__init__(rect=(x, y, width * numNums, numbers.get_height()), enabled=True)
self._numbers = []
self._digits = []
self._maxTime = maxTime
self._currentTime = maxTime
self._blank = Display(Surface((width, self.h)))
for i in range(width):
self._numbers.append(Display(numbers.subsurface((i * width, 0, width, self.h))))
surf = Surface((self.w + 2 * numNums, self.h))
self._display = Display(surf, self, transparent=True, alpha=200)
for i in range(numNums):
self._digits.append(surf.subsurface((i * width + 2 * i, 0, width, self.h)))
self._lastUpdate = -maxTime