本文整理汇总了Python中ball.Ball.collides方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.collides方法的具体用法?Python Ball.collides怎么用?Python Ball.collides使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.collides方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import collides [as 别名]
def start(size):
main_clock = pygame.time.Clock()
pygame.display.init()
window = pygame.display.set_mode(size)
window_ = window.copy()
b = Ball()
r_right = Racket('R')
r_left = Racket('L')
while True:
# Event manager
for event in pygame.event.get():
if event.type == QUIT:
end()
elif event.type == MOUSEBUTTONDOWN:
if event.button == 1:
pass
elif event.type == KEYDOWN:
#print(event.key)
if event.key == 273: # Direction key up
r_right.direction = 'up'
break
if event.key == 274: # Direction key down
r_right.direction = 'down'
break
r_right.direction = False
window.blit(window_, (0, 0))
r_right.draw(window)
r_right.update()
r_left.computerAI(b)
r_left.draw(window)
r_left.update()
b.draw(window)
b.update()
b.collides(r_right, r_left)
Interface.draw(window, r_left.mark, r_right.mark)
pygame.display.flip()
main_clock.tick(100)