import pygame ## This recursive function draws a circle with increasingly smaller ## circles nested inside. (I use yet another option of how to make ## sure that the colors are alternating.) def draw_recursive_circle(win, x, y, radius, color, othercolor): pygame.draw.circle(win, color, (x,y), radius) if radius > 20: draw_recursive_circle(win, x, y, radius-20, othercolor, color) def run_game(): ## Initialize the pygame submodules and set up the display window. pygame.init() width = 640 height = 480 my_win = pygame.display.set_mode((width,height)) ## The game loop starts here. keepGoing = True while (keepGoing): ## Handle events. for event in pygame.event.get(): if event.type == pygame.QUIT: keepGoing = False ## Draw picture and update display my_win.fill(pygame.color.Color("darkblue")) draw_recursive_circle(my_win, width/2, height/2, height/2, pygame.color.Color("orange"), pygame.color.Color("magenta")) pygame.display.update() ## The game loop ends here. pygame.quit() ## Call the function run_game. run_game()