本文整理汇总了Python中square.Square.pos方法的典型用法代码示例。如果您正苦于以下问题:Python Square.pos方法的具体用法?Python Square.pos怎么用?Python Square.pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类square.Square
的用法示例。
在下文中一共展示了Square.pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Square
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import pos [as 别名]
pygame.init()
screen = pygame.display.set_mode((700, 500))
pygame.display.set_caption("Gravitation")
square = Square(screen, 325, 0, 50, 50)
square.acceleration = Vector(0, 200)
clock = pygame.time.Clock()
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
t = clock.get_time() / 1000
if square.pos.y >= screen.get_size()[1] - 50:
square.pos = Vector(325, screen.get_size()[1] - 50)
square.velocity = -square.velocity/1.2
if abs(square.velocity) <= 10:
square.velocity = Vector(0, 0)
square.acceleration = Vector(0, 0)
square.update(t)
screen.fill((0, 0, 0))
square.draw()
pygame.display.flip()
clock.tick(60)