import pygame import sys # Initialize pygame pygame.init() # Screen dimensions WIDTH = 800 HEIGHT = 600 # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Fonts font = pygame.font.Font(None, 36) # Menu options options = ["Shooter", "Platformer", "1v1", "Exit"] # Set up the screen screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Pygame Title Page") def display_menu(): screen.fill(WHITE) title_text = font.render("Games List", True, BLACK) title_rect = title_text.get_rect(center=(WIDTH // 2, 100)) screen.blit(title_text, title_rect) for i, option in enumerate(options): text = font.render(option, True, BLACK) text_rect = text.get_rect(center=(WIDTH // 2, 250 + i * 50)) screen.blit(text, text_rect) def return_to_title_page(): global score, lives # Reset any game variables or state score = 0 lives = 5 # Return to the title page loop title_page_loop() def run_project(project, return_to_title_page): if project == "Shooter": import project1 project1.main() return_to_title_page() elif project == "Platformer": import project2 project2.main(return_to_title_page) elif project == "1v1": import project3 # Import your new game module project3.main() # Call the main function of your new game return_to_title_page() def title_page_loop(): # Main loop for the title page running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: pos = pygame.mouse.get_pos() for i, _ in enumerate(options): if (WIDTH // 2 - 100) < pos[0] < (WIDTH // 2 + 100) and (225 + 50 * i) < pos[1] < (275 + 50 * i): selected_option = options[i] if selected_option == "Exit": pygame.quit() sys.exit() else: run_project(selected_option, return_to_title_page) display_menu() pygame.display.flip() # Start with the title page loop title_page_loop()