# Homework 33 solution, challenge: mouse follower. # Run with: python exercises/33/homework/solutions/04-mouse-follower.py import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Mouse Follower") clock = pygame.time.Clock() button_held = False running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: button_held = True if event.type == pygame.MOUSEBUTTONUP: if event.button == 1: button_held = False mx, my = pygame.mouse.get_pos() color = (255, 255, 0) if button_held else (200, 200, 200) screen.fill((30, 30, 30)) pygame.draw.circle(screen, color, (mx, my), 15) pygame.display.flip() clock.tick(60) pygame.quit()