import pygame
import time
import random
# Initialize pygame
pygame.init()
# Set up the display
width, height = 600, 400
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Matrix Digital Clock")
# Set up colors
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
# Set up fonts
font = pygame.font.Font(None, 120)
# Function to render the time
def draw_time():
# Get the current time
current_time = time.strftime("%H:%M:%S")
# Create a surface with the time text
text_surface = font.render(current_time, True, GREEN)
text_rect = text_surface.get_rect(center=(width // 2, height // 2))
# Clear the screen and draw the time
screen.fill(BLACK)
screen.blit(text_surface, text_rect)
# Main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Draw the time on the screen
draw_time()
# Update the display
pygame.display.update()
# Delay for 1 second
pygame.time.delay(1000)
# Quit pygame
pygame.quit()