import pygame def main(): #1 pygame.init() # Prepare the pygame module for use windowSize = (800, 600) # Desired physical surface size, in pixels. # Create surface of (width, height), and its window. main_surface = pygame.display.set_mode(windowSize) #2 # Set up some data to describe a small rectangle and its color small_rect = (300, 200, 150, 90) some_color = (255, 0, 0) # A color is a mix of (Red, Green, Blue) #3 while True: #3.1 ev = pygame.event.poll() # Look for any event if ev.type == pygame.QUIT: # Window close button clicked? break # ... leave game loop #3.2 # Update your game objects and data structures here... #3.3 # We draw everything from scratch on each frame. # So first fill everything with the background color main_surface.fill((0, 200, 255)) # Overpaint a smaller rectangle on the main surface main_surface.fill(some_color, small_rect) #3.4 # Now the surface is ready, tell pygame to display it! pygame.display.flip() #4 #5 pygame.quit() # Once we leave the loop, close the window. main()