## Everything following a '#' is a 'comment'. Comments are ## explanations for the programmer or other human beings looking at ## the code. The Python interpreter ignores them. ## All lines that do not start with a '#', are instructions for the ## Python interpreter. ## Load the pygame library, so that we can use the ## functionality it provides. import pygame ## Initialize the pygame submodules. pygame.init() ## Open the pygame window with the specified ## width and height. ## We call our pygame window 'my_win'. width = 640 height = 480 my_win = pygame.display.set_mode((width,height)) ## This is the "game loop". We will talk much more about the game ## loop next week. For now: the game loop keeps the pygame window ## on the screen until you click the 'X' in the upper right hand ## corner. keepGoing = True while (keepGoing): ###### START: This is the beginning of the part that you need to ###### look at for this first lab exercise. my_win.fill(pygame.color.Color("black")) pygame.draw.rect(my_win, pygame.color.Color('white'), (100,100,50,50)) pygame.draw.rect(my_win, pygame.color.Color('darkmagenta'), (140,140,70,40)) pygame.draw.circle(my_win, pygame.color.Color('navy'), (500,250),75) pygame.draw.line(my_win,pygame.color.Color('deeppink'),(50,320),(550,200)) pygame.draw.polygon(my_win,pygame.color.Color('darkgreen'), [(150,300),(150+80,300),(150+40,300+120)]) ###### END: This is the end of the part that you need to look at ###### for this first lab exercise. ## Show the pygame window. pygame.display.update() ## Here we check whether somebody clicked the 'X' in the upper right ## hand corner of the pygame window. for event in pygame.event.get(): if event.type == pygame.QUIT: keepGoing = False ## This closes your pygame window. pygame.quit()