本文整理匯總了Python中rect.Rect.bottom方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.bottom方法的具體用法?Python Rect.bottom怎麽用?Python Rect.bottom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rect.Rect
的用法示例。
在下文中一共展示了Rect.bottom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import bottom [as 別名]
def update(self):
last = Rect(*(self.pos + self.size))
dx = 0
if keys.get(Keyboard.keycodes['left']):
dx -= 2 * params.scale
if keys.get(Keyboard.keycodes['right']):
dx += 2 * params.scale
if keys.get(Keyboard.keycodes['spacebar']) and self.resting:
self.dy = 9 * params.scale
self.resting = False
self.dy = max(-8 * params.scale, self.dy - .5 * params.scale)
self.x += dx
self.y += self.dy
new = Rect(*(self.pos + self.size))
for cell in self.map.layers['objects'].collide(new, 'blocker'):
blocker = cell['blocker']
if 'l' in blocker and last.right <= cell.left and new.right > cell.left:
new.right = cell.left
if 'r' in blocker and last.left >= cell.right and new.left < cell.right:
new.left = cell.right
if 't' in blocker and last.bottom >= cell.top and new.bottom < cell.top:
self.resting = True
new.bottom = cell.top
self.dy = 0
if 'b' in blocker and last.top <= cell.bottom and new.top > cell.bottom:
new.top = cell.bottom
self.dy = 0
self.pos = new.bottomleft