# Name: snowman.py # Date: April 8, 2011 # Author: Mr. Cargill # Purpose: Draw a snowman on the screen import pygame, sys, os from pygame.locals import * os.environ['SDL_VIDEODRIVER'] = 'windib' # Set appropriate video driver os.environ["SDL_VIDEO_CENTERED"] = `1` # Center pygame window on screen pygame.init() screen = pygame.display.set_mode((800,600)) pygame.display.set_caption("Snowman") # Set Window Title # Make the Background Light Blue screen.fill((173, 216, 230)) # Draw the Head pygame.draw.circle(screen,(255,255,255),(400,100),50) # Draw the Hat pygame.draw.ellipse(screen, (0,0,0),(365,20,70,20),0) pygame.draw.ellipse(screen, (0,0,0),(350,60,100,20),0) pygame.draw.polygon(screen, (0,0,0),[(365,25),(435,25),(435,65),(365,65)],0) # Draw the Eyes (Snowman will be looking to his right (our left)) pygame.draw.circle(screen,(0,0,0),(365,88),5) pygame.draw.circle(screen,(0,0,0),(395,88),5) # Draw the Mouth pygame.draw.circle(screen,(0,0,0),(365,110),3) pygame.draw.circle(screen,(0,0,0),(372,114),3) pygame.draw.circle(screen,(0,0,0),(380,116),3) pygame.draw.circle(screen,(0,0,0),(387,114),3) pygame.draw.circle(screen,(0,0,0),(395,110),3) # Draw the Nose pygame.draw.polygon(screen, (237,145,33),[(380,90),(380,98),(355,96)],0) # Draw the Upper Body pygame.draw.circle(screen,(255,255,255),(400,237),100) # Draw the Left Arm pygame.draw.polygon(screen, (139,90,43),[(460,235),(470,237),(430,275),(400,226),(430,260),(470,227),(470,225)],0) pygame.draw.polygon(screen, (139,90,43),[(410,236),(395,245),(405,236)],0) # Draw the Right Arm pygame.draw.polygon(screen, (139,90,43),[(300,226),(275,236),(250,255),(300,233)],0) pygame.draw.polygon(screen, (139,90,43),[(270,245),(255,275),(265,245)],0) # Draw the Lower Body pygame.draw.circle(screen,(255,255,255),(400,450),150) # Draw the Snow on the Ground pygame.draw.polygon(screen, (255,255,255), [(0,600),(0,580),(25,585),(400,570),(775,570),(800,575),(800,600)]) # Event loop while True: for event in pygame.event.get(): if event.type==QUIT: sys.exit() pygame.display.flip()