import pygame import sys # Setup pygame.init() screen = pygame.display.set_mode((400, 300)) pygame.display.set_caption("AFK Protector") font = pygame.font.SysFont("Arial", 24) # State protection_menu = False protection_active = False show_password_prompt = False password_input = "" correct_password = "1234" message = "" clock = pygame.time.Clock() def draw_text(text, y, center=True, color=(255,255,255)): txt = font.render(text, True, color) rect = txt.get_rect(center=(200, y) if center else (10, y)) screen.blit(txt, rect) while True: screen.fill((20, 20, 30)) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() # Handle global key (F2 toggles menu) if event.type == pygame.KEYDOWN: if event.key == pygame.K_F2 and not protection_active: protection_menu = not protection_menu # Handle Protection Mode if protection_active: if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEMOTION: show_password_prompt = True protection_active = False # Password prompt input if show_password_prompt and event.type == pygame.KEYDOWN: if event.key == pygame.K_BACKSPACE: password_input = password_input[:-1] elif event.key == pygame.K_RETURN: if password_input == correct_password: show_password_prompt = False password_input = "" message = "Unlocked." else: password_input = "" message = "Wrong code." else: if len(password_input) < 10: password_input += event.unicode # Start protection if menu is up if protection_menu: if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN: protection_active = True protection_menu = False message = "Protection Active" # Draw interface if protection_menu: draw_text("Start Protection? Press Enter", 130) elif protection_active: draw_text("Protection Enabled", 130) elif show_password_prompt: draw_text("Enter Code:", 100) hidden_code = "123" * len(password_input) draw_text(hidden_code, 140) draw_text(message, 180, color=(255, 100, 100)) else: draw_text("Press F2 to open protection", 130) draw_text(message, 180, color=(0, 255, 0)) pygame.display.flip() clock.tick(30)