import pygame import datetime import os # Initialize Pygame pygame.init() # Set the path for the flag image file flag_path = os.path.join(os.path.dirname(__file__), 'usaflag.jpg') # Load the flag image flag_image = pygame.image.load(flag_path) # Set the window size DISPLAY_WIDTH = 1200 DISPLAY_HEIGHT = 600 # Set the font font = pygame.font.Font(None, 36) title_font = pygame.font.Font(None, 48) # Set the countdown date and time COUNTDOWN_DATE = datetime.datetime(2023, 9, 20, 11, 0, 0) # Create the window screen = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT)) pygame.display.set_caption("USA BABY") # Get the size of the flag image flag_width, flag_height = flag_image.get_size() # Calculate the position to center the flag image on the background flag_x = (DISPLAY_WIDTH - flag_width) // 2 flag_y = (DISPLAY_HEIGHT - flag_height) // 2 # Blit the flag image onto the background screen.blit(flag_image, (flag_x, flag_y)) # Set the initial text color text_color = (0, 0, 0) # Set the color change interval color_change_interval = datetime.timedelta(seconds=1) next_color_change_time = datetime.datetime.now() + color_change_interval # Create the title text title_text = "USA BABY!" title_surface = title_font.render(title_text, True, (255, 255, 255)) title_rect = title_surface.get_rect() title_rect.center = (DISPLAY_WIDTH // 2, 50) # Main game loop while True: # Get the current time current_time = datetime.datetime.now() # Calculate the time remaining time_remaining = COUNTDOWN_DATE - current_time time_remaining = time_remaining - datetime.timedelta(microseconds=time_remaining.microseconds) # Quit Pygame if the window is closed for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() # Alternate the text color between white and red every second if current_time >= next_color_change_time: next_color_change_time += color_change_interval if text_color == (0, 0, 255): text_color = (255, 255, 255) else: text_color = (0, 0, 255) # Clear the screen screen.fill((0, 0, 0)) # Blit the flag image onto the background screen.blit(flag_image, (flag_x, flag_y)) # Render the title text title_surface = title_font.render(title_text, True, (255, 255, 255)) title_rect = title_surface.get_rect() title_rect.center = (DISPLAY_WIDTH // 2, 50) screen.blit(title_surface, title_rect) # Render the time remaining as text text = font.render(str(time_remaining), True, text_color) text_rect = text.get_rect() text_rect.center = (DISPLAY_WIDTH // 2, DISPLAY_HEIGHT // 2) screen.blit(text, text_rect) # Update the screen pygame.display.update()