import pygame import sys # Initialize Pygame pygame.init() # Set screen dimensions WIDTH, HEIGHT = 800, 600 SCREEN = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Main Menu") # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Fonts font = pygame.font.Font(None, 36) # Function to display text on screen def draw_text(text, font, color, surface, x, y): text_obj = font.render(text, True, color) text_rect = text_obj.get_rect() text_rect.center = (x, y) surface.blit(text_obj, text_rect) # Main menu function def main_menu(): while True: SCREEN.fill(WHITE) draw_text("First Person", font, BLACK, SCREEN, WIDTH // 2, HEIGHT // 4) # Play button pygame.draw.rect(SCREEN, BLACK, (300, 250, 200, 50)) draw_text("Play", font, WHITE, SCREEN, WIDTH // 2, HEIGHT // 2.2) # Quit button pygame.draw.rect(SCREEN, BLACK, (300, 350, 200, 50)) draw_text("Quit", font, WHITE, SCREEN, WIDTH // 2, HEIGHT // 2.2 + 100) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if 300 <= mouse_pos[0] <= 500 and 250 <= mouse_pos[1] <= 300: # Start game function start_game() elif 300 <= mouse_pos[0] <= 500 and 350 <= mouse_pos[1] <= 400: pygame.quit() sys.exit() # Function to start the game def start_game(): pass # Implement your game here # Run the main menu main_menu()