#NEWLINE# def bounce( ) : #NEWLINE# #INDENT# 'This is a basic example function, extending the previous\n    example.' #NEWLINE# xlen = 10 #NEWLINE# b1 = box ( size = ( 1 , 4 , 4 ) , color = ( 0 , 1 , 0 ) ) #NEWLINE# b2 = box ( size = ( 1 , 4 , 4 ) , color = ( 0 , 1 , 0 ) , pos = ( xlen , 0 , 0 ) ) #NEWLINE# s = sphere ( radius = 0.5 , pos = ( xlen , 0 , 0 ) , color = ( 1 , 0 , 0 ) ) #NEWLINE# s . velocity = ( ( - 1 ) , 0 , 0 ) #NEWLINE# def anim( ) : #NEWLINE# #INDENT# x = s . x #NEWLINE# if ( x == 1 ) : #NEWLINE# #INDENT# s . velocity = ( 1 , 0 , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( x == ( xlen - 1 ) ) : #NEWLINE# #INDENT# s . velocity = ( ( - 1 ) , 0 , 0 ) #NEWLINE# #UNINDENT# #UNINDENT# s . x = ( x + s . velocity [ 0 ] ) #NEWLINE# #UNINDENT# t = iterate ( 60 , anim ) #NEWLINE# t . edit_traits ( ) #NEWLINE# return t