-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpygame-gpt4o.py
58 lines (44 loc) · 1.25 KB
/
pygame-gpt4o.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pygame
import math
# Initialize Pygame
pygame.init()
# Screen dimensions and setup
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Concentric Circles Animation")
# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
# Clock for controlling frame rate
clock = pygame.time.Clock()
# Circle properties
CENTER = (WIDTH // 2, HEIGHT // 2)
OUTER_RADIUS = 150
INNER_RADIUS = 20
angular_velocity = 0.05 # radians per frame
angle = 0 # Initial angle
# Main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Clear screen
screen.fill(BLACK)
# Update angle for outer circle rotation
angle += angular_velocity
# Calculate inner circle position
inner_x = CENTER[0] + OUTER_RADIUS * math.cos(angle)
inner_y = CENTER[1] + OUTER_RADIUS * math.sin(angle)
# Draw outer circle
pygame.draw.circle(screen, BLUE, CENTER, OUTER_RADIUS, 2)
# Draw inner circle
pygame.draw.circle(screen, RED, (int(inner_x), int(inner_y)), INNER_RADIUS)
# Update display
pygame.display.flip()
# Cap the frame rate
clock.tick(60)
# Quit Pygame
pygame.quit()