Untitled
plain_text
24 days ago
1.1 kB
1
Indexable
Never
import pygame import sys # Initialize Pygame pygame.init() # Set up display screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("Background with Trees and Sun") # Colors white = (255, 255, 255) blue = (135, 206, 235) green = (0, 128, 0) yellow = (255, 255, 0) # Draw background screen.fill(blue) # Draw sun pygame.draw.circle(screen, yellow, (100, 100), 50) # Draw trees tree_positions = [(200, 350), (500, 400), (700, 300)] for position in tree_positions: pygame.draw.rect(screen, green, (position[0] - 20, position[1], 40, 100)) pygame.draw.polygon(screen, green, [(position[0] - 60, position[1]), (position[0] + 60, position[1]), (position[0], position[1] - 80)]) # Main loop running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.display.flip() # Quit Pygame pygame.quit() sys.exit()