| 56 | x, y = event.x, event.y |
| 57 | |
| 58 | def update(): |
| 59 | try: |
| 60 | ident = screen.after(1000 / FPS, update) |
| 61 | for mutate in container, governor: |
| 62 | for ball in balls: |
| 63 | mutate(ball) |
| 64 | for index, ball_1 in enumerate(balls[:-1]): |
| 65 | for ball_2 in balls[index+1:]: |
| 66 | ball_1.crash(ball_2) |
| 67 | for ball in balls: |
| 68 | ball.move(FPS) |
| 69 | screen.delete(ALL) |
| 70 | for ball in balls: |
| 71 | x1 = ball.pos.x - BALL_RADIUS |
| 72 | y1 = ball.pos.y - BALL_RADIUS |
| 73 | x2 = ball.pos.x + BALL_RADIUS |
| 74 | y2 = ball.pos.y + BALL_RADIUS |
| 75 | screen.create_oval(x1, y1, x2, y2, fill=BALL_COLOR) |
| 76 | except: |
| 77 | screen.after_cancel(ident) |
| 78 | screen.delete(ALL) |
| 79 | screen.create_text(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, text=format_exc(), font='Courier 10', fill='red') |
| 80 | |
| 81 | def container(ball): |
| 82 | space = WALL_SPACE + BALL_RADIUS |