本文整理汇总了Python中pygame.rect.Rect.midbottom方法的典型用法代码示例。如果您正苦于以下问题:Python Rect.midbottom方法的具体用法?Python Rect.midbottom怎么用?Python Rect.midbottom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.rect.Rect
的用法示例。
在下文中一共展示了Rect.midbottom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startGame
# 需要导入模块: from pygame.rect import Rect [as 别名]
# 或者: from pygame.rect.Rect import midbottom [as 别名]
def startGame():
background = pygame.surface.Surface(RESOLUTION)
background = pygame.image.load(BACKGROUND).convert()
screen.blit(background, ((0, 0),RESOLUTION))
# Create title from image
titleSize = ((int(RESOLUTION[0] * .75)), (int(RESOLUTION[0] * .3)))
titleRect = Rect((0, 0), titleSize)
titleRect.midtop = (screen.get_rect().centerx, 20)
titleSurf = pygame.surface.Surface(titleSize)
title = Widget(titleSurf, titleRect)
tempImage = pygame.image.load('images/title.png').convert()
tempImage = pygame.transform.scale(tempImage, titleSize)
tempImage.set_colorkey(PUCE, RLEACCEL)
title.image = tempImage
# Create animated bomb on screen
bombRect = Rect((0, 0), (200, 200))
bombRect.centerx = screen.get_rect().centerx
bombRect.centery = screen.get_rect().centery
bombSurf = pygame.surface.Surface((200, 200))
bomb = Widget(bombSurf, bombRect)
tempImage = pygame.image.load('images/bomb/bomb_strip_title.png').convert()
bombFrames = createFrames(tempImage)
bomb.image = bombFrames[0]
# Create 'Press any Key' message from image
pressKeySize = ((int(RESOLUTION[0] * .75)), (int(RESOLUTION[0] * .15)))
pressKeySurf = pygame.surface.Surface(pressKeySize)
pressKeyRect = Rect((0, 0), pressKeySize)
pressKeyRect.midbottom = screen.get_rect().midbottom
pressKey = Widget(pressKeySurf, pressKeyRect)
tempImage = pygame.image.load('images/press_key.png').convert()
tempImage = pygame.transform.scale(tempImage, pressKeySize)
tempImage.set_colorkey(PUCE, RLEACCEL)
pressKey.image = tempImage
myGroup = SpriteGroup()
myGroup.add(title)
myGroup.add(bomb)
myGroup.add(pressKey)
pygame.display.flip()
i = 0
MaxFR = 15
lastUpdate = t.time()
frameTime = 1.0 / float(MaxFR)
while 1:
pygame.event.pump()
for event in pygame.event.get():
if event.type == KEYDOWN or event.type == JOYBUTTONDOWN:
return
if event.type == QUIT:
s.exit()
bomb.image = bombFrames[i]
myGroup.clear(screen, background)
myGroup.update()
dirty = myGroup.draw(screen)
pygame.display.update(dirty)
if t.time() > lastUpdate + frameTime:
i = (i+1) % 4
lastUpdate = t.time()