MCPcopy Create free account
hub / github.com/ActiveState/code / update

Function update

recipes/Python/502253_Space_Balls/recipe-502253.py:58–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56 x, y = event.x, event.y
57
58def 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
81def container(ball):
82 space = WALL_SPACE + BALL_RADIUS

Callers

nothing calls this directly

Calls 7

format_excFunction · 0.85
mutateFunction · 0.50
enumerateFunction · 0.50
afterMethod · 0.45
crashMethod · 0.45
moveMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected