#NEWLINE# def spawn_ball( space , position , direction ) : #NEWLINE# #INDENT# ball_body = pymunk . Body ( 1 , pymunk . inf ) #NEWLINE# ball_body . position = position #NEWLINE# ball_shape = pymunk . Circle ( ball_body , 5 ) #NEWLINE# ball_shape . color = THECOLORS [ 'green' ] #NEWLINE# ball_shape . elasticity = 1.0 #NEWLINE# ball_body . apply_impulse ( Vec2d ( direction ) ) #NEWLINE# def constant_velocity( body , gravity , damping , dt ) : #NEWLINE# #INDENT# body . velocity = ( body . velocity . normalized ( ) * 400 ) #NEWLINE# #UNINDENT# ball_body . velocity_func = constant_velocity #NEWLINE# space . add ( ball_body , ball_shape )