def update():
try:
ident = screen.after(1000 / FPS, update)
for mutate in container, governor:
for ball in balls:
mutate(ball)
for index, ball_1 in enumerate(balls[:-1]):
for ball_2 in balls[index+1:]:
ball_1.crash(ball_2)
for ball in balls:
ball.move(FPS)
screen.delete(ALL)
for ball in balls:
x1 = ball.pos.x - BALL_RADIUS
y1 = ball.pos.y - BALL_RADIUS
x2 = ball.pos.x + BALL_RADIUS
y2 = ball.pos.y + BALL_RADIUS
screen.create_oval(x1, y1, x2, y2, fill=BALL_COLOR)
except:
screen.after_cancel(ident)
screen.delete(ALL)
screen.create_text(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, text=format_exc(), font='Courier 10', fill='red')
评论列表
文章目录