def main(): """ This program simulates a bouncing ball at (START_X, START_Y) that has VX as x velocity and 0 as y velocity. Each bounce reduces y velocity to REDUCE of itself. """ global times,switch,VY ball=GOval(SIZE,SIZE,x=START_X,y=START_Y) ball.filled= True ball.fill_color='black' window.add(ball) switch = False onmouseclicked(turn_on) while True: pause(DELAY) if switch==True: VY+=GRAVITY ball.move(VX,VY) pause(DELAY) if ball.y>window.height: VY=-REDUCE*VY if ball.x>window.width: ball.x=START_X ball.y=START_Y times +=1 if times>=3: break else: pass
def circles(): """ Draw circles in Fibonacci sequence. :return: Nothing. """ m = 1 # First number. n = 1 # Second number. max_n = math.sqrt(window.width**2/2) * 2 # Use window width to calculate max diameter needed. while n <= max_n: fib = m+n circle = GOval(fib, fib) circle.color = 'white' circle.x = center_x - fib//2 # Center circle. circle.y = center_y - fib//2 window.add(circle) m = n # Update first number with second number. n = fib # Update second number with sum. return