# Untitled

unknown
plain_text
a year ago
2.0 kB
2
Indexable
Never
```import pygame
import time

# Initialize pygame
pygame.init()

# Set the clock's size and position
size = (700, 700)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Analog Clock")

# Set the clock's background color
bg_color = (255, 255, 255)

# Create a function to draw the clock
def draw_clock():
# Get the current time
current_time = time.strftime("%H:%M:%S")
hours, mins, secs = current_time.split(":")

# Convert the time to angles
hours_angle = (int(hours) / 12) * 360
mins_angle = (int(mins) / 60) * 360
secs_angle = (int(secs) / 60) * 360

# Clear the screen
screen.fill(bg_color)

# Draw the clock's outline
pygame.draw.circle(screen, (0, 0, 0), (350, 350), 300, 5)

# Draw the clock's ticks
for i in range(12):
tick_angle = (i / 12) * 360
tick_x, tick_y = calculate_point(tick_angle, 250)
pygame.draw.line(screen, (0, 0, 0), (350, 350), (350 + tick_x, 350 + tick_y), 5)

# Draw the clock's hands
hour_x, hour_y = calculate_point(hours_angle, 150)
min_x, min_y = calculate_point(mins_angle, 200)
sec_x, sec_y = calculate_point(secs_angle, 250)
pygame.draw.line(screen, (0, 0, 0), (350, 350), (350 + hour_x, 350 + hour_y), 8)
pygame.draw.line(screen, (0, 0, 0), (350, 350), (350 + min_x, 350 + min_y), 5)
pygame.draw.line(screen, (255, 0, 0), (350, 350), (350 + sec_x, 350 + sec_y), 2)

# Update the display
pygame.display.flip()

# Create a function to calculate the point on the clock's face for a given angle and distance
def calculate_point(angle, distance):
x = distance * -1 * math.sin(math.radians(angle))
return (x, y)

# Main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

# Draw the clock
draw_clock()

# Wait for 1 second
time.sleep(1)

# Exit pygame
pygame.quit()
```