import pygame from datetime import datetime # initialize pygame pygame.init() # set the dimensions of the screen screen_width = 600 screen_height = 400 # create the screen screen = pygame.display.set_mode((screen_width, screen_height)) # set the title of the window pygame.display.set_caption("USA BABY") # define the colors of the American flag red = (191, 10, 48) blue = (0, 40, 104) white = (255, 255, 255) # set the font for the countdown timer font = pygame.font.Font(None, 50) # set the target date for the countdown target_date = datetime(2023, 9, 20) # define a function to update the countdown timer def update_timer(): current_date = datetime.now() time_diff = target_date - current_date seconds = int(time_diff.total_seconds()) minutes = seconds // 60 hours = minutes // 60 days = hours // 24 countdown = "{:02d}:{:02d}:{:02d}".format(days, hours % 24, minutes % 60) return countdown # main loop while True: # check for events for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() # draw the background (white) screen.fill(white) # draw the stripes of the flag stripe_height = screen_height // 13 for i in range(13): if i % 2 == 0: color = red else: color = white pygame.draw.rect(screen, color, pygame.Rect(0, i * stripe_height, screen_width, stripe_height)) # draw the blue field of the flag field_width = 0.4 * screen_width field_height = 7 * stripe_height field_rect = pygame.Rect(0, 0, field_width, field_height) pygame.draw.rect(screen, blue, field_rect) # draw the stars on the blue field star_size = int(0.03 * screen_width) star_spacing = int(0.063 * screen_width) star_offset_x = int(0.063 * screen_width) star_offset_y = int(0.054 * screen_height) for i in range(6): for j in range(5): if j % 2 == 0: x = i * star_spacing + star_offset_x else: x = i * star_spacing + star_offset_x + star_spacing // 2 y = j * star_spacing + star_offset_y pygame.draw.polygon(screen, white, [(x, y), (x + star_size, y + star_size // 3), (x + star_size * 2 // 3, y + star_size // 2), (x + star_size, y + star_size * 2 // 3), (x, y + star_size * 2 // 3), (x + star_size // 3, y + star_size // 2)]) # draw the countdown timer countdown = update_timer() countdown_text = font.render(countdown, True, blue) countdown_rect = countdown_text.get_rect(center=(screen_width // 2, screen_height // 2)) screen.blit(countdown_text, countdown_rect) # update the display pygame.display.update()