本文整理汇总了Python中Block.Block.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Block.draw方法的具体用法?Python Block.draw怎么用?Python Block.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block.Block
的用法示例。
在下文中一共展示了Block.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Block import Block [as 别名]
# 或者: from Block.Block import draw [as 别名]
def main():
# Initialize
pygame.init()
'''block size = 20 x 20 pixels'''
screen = pygame.display.set_mode((200, 400))
area = screen.get_rect()
pygame.display.set_caption('Destroy all blocks! DO EEET!')
pygame.mouse.set_visible(False)
# Create the background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
# Display the background
screen.blit(background, (0, 0))
pygame.display.flip()
# Prepare game objects
clock = pygame.time.Clock()
block = Block('red', (4,0), 20)
count = 0
maxCount = 30
# Main Loop
gameNotOver = True
while gameNotOver:
clock.tick(60)
# Handle Input Events
for event in pygame.event.get():
if event.type == QUIT:
gameNotOver = False
# Move things based on current state
if count >= maxCount:
count = 0
x, y = block.position
block.changePosition((x, y+1))
else:
count += 1
if block.rect.bottom >= area.bottom:
gameNotOver = False
# Draw everything
screen.blit(background, (0, 0))
block.draw(screen)
pygame.display.flip()
pygame.quit()