| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import pygame
- import sys
- # Initialize Pygame
- pygame.init()
- # Set up the display
- width, height = 800, 600
- screen = pygame.display.set_mode((width, height))
- pygame.display.set_caption("Draw a Circle")
- # Define colors
- WHITE = (255, 255, 255)
- BLUE = (0, 102, 255)
- # Circle parameters
- circle_center = (width // 2, height // 2)
- circle_radius = 75
- # Main loop
- running = True
- while running:
- # Handle events
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- # Fill the background
- screen.fill(WHITE)
- # Draw the circle
- pygame.draw.circle(screen, BLUE, circle_center, circle_radius)
- # Update the display
- pygame.display.flip()
- # Quit Pygame
- pygame.quit()
- sys.exit()
|