import pygame, sys pygame.init() display = pygame.display.set_mode((300,300)) display.fill((255,255,255)) # Drawing a polygon on the display surface using Pygame's draw.polygon() function. pygame.draw.polygon(display, (0,0,255), [(120,120), (40,160), (40,220), (200,220), (200,160)], width=0) # display: The surface to draw the polygon on. # (0, 0, 255): The color of the polygon in RGB format, here it represents blue color. # [(120, 120), (40, 160), (40, 220), (200, 220), (200, 160)]: The list of vertices of the polygon. # Each vertex is represented as a tuple (x, y) coordinate. # The lines will be drawn connecting consecutive vertices in the list. # width=0: The width of the outline of the polygon. # Setting it to 0 means that the polygon will be filled with the specified color. while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() pygame.display.update()