import pygame import math import sys # Initialize Pygame pygame.init() # Constants WIDTH, HEIGHT = 800, 600 FPS = 60 # Set up the display screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN) pygame.display.set_caption("Rotating Illusion") def draw_rotating_pattern(angle): # Fill the screen with white screen.fill((255, 255, 255)) # Draw a rotating pattern for i in range(50): for j in range(50): # Calculate position to cover the screen x = (i * (WIDTH // 50)) # Adjust size to fit screen y = (j * (HEIGHT // 50)) # Adjust size to fit screen # Calculate rotation offset_x = int(30 * math.cos(angle + (i + j) * 0.1)) offset_y = int(30 * math.sin(angle + (i + j) * 0.1)) # Added missing parenthesis here color = (0, 0, 0) if (i + j) % 2 == 0 else (255, 255, 255) pygame.draw.rect(screen, color, (x + offset_x, y + offset_y, (WIDTH // 50), (HEIGHT // 50))) # Draw a red dot in the center pygame.draw.circle(screen, (255, 0, 0), (WIDTH // 2, HEIGHT // 2), 10) def main(): clock = pygame.time.Clock() angle = 0 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() draw_rotating_pattern(angle) pygame.display.flip() angle += 0.05 # Increase the angle for rotation clock.tick(FPS) if __name__ == "__main__": main()