# Importing the Pygame library for building games and multimedia applications. import pygame # Importing the sys module to exit the program. import sys # Importing constants from pygame.locals module. from pygame.locals import * # Initializing all Pygame modules. pygame.init() # Creating a window surface with a size of 300x300 pixels. displaysurface = pygame.display.set_mode((300,300)) # Creating a surface with a size of 50x50 pixels and filling it with green color. mySurface = pygame.Surface((50,50)) mySurface.fill((0,255,0)) # Creating another surface with a size of 100x50 pixels and filling it with green color. mySurface2 = pygame.Surface((100,50)) mySurface2.fill((0,255,0)) # Main game loop that runs indefinitely until the program is exited. while True: # Iterating through each event that has occurred. for event in pygame.event.get(): # If the event is the user closing the window... if event.type == QUIT: # ...quit Pygame and exit the program. pygame.quit() sys.exit() # Drawing the first surface at position (50,50) on the display surface. displaysurface.blit(mySurface, (50,50)) # Drawing the second surface at position (50,150) on the display surface. displaysurface.blit(mySurface2, (50,150)) # Updating the display to show any changes. pygame.display.update()