import { Target, CONSTANTS } from '../types'; export const generateTargets = () => { const newTargets: Target[] = []; // Fixed target size for better visibility const MIN_RADIUS = 100; const MAX_RADIUS = 600; // Get browser window dimensions const windowWidth = window.innerWidth; const windowHeight = window.innerHeight; // Base the target area on the minimum zoom level // This ensures when fully zoomed out, we see the entire grid const minZoom = CONSTANTS.ZOOM_LEVELS.min; const areaWidth = windowWidth / minZoom; const areaHeight = windowHeight / minZoom; // Create a grid-like distribution const gridSize = Math.ceil(Math.sqrt(CONSTANTS.TARGET_COUNT)); const cellWidth = areaWidth / gridSize; const cellHeight = areaHeight / gridSize; for (let i = 0; i < CONSTANTS.TARGET_COUNT; i++) { // Calculate grid position const gridX = i % gridSize; const gridY = Math.floor(i / gridSize); // Add some randomness within each grid cell const randomOffsetX = (Math.random() - 0.5) * cellWidth * 0.6; const randomOffsetY = (Math.random() - 0.5) * cellHeight * 0.6; // Calculate final position const x = cellWidth * (gridX + 0.5) + randomOffsetX; const y = cellHeight * (gridY + 0.5) + randomOffsetY; // Random radius const radius = MIN_RADIUS + Math.random() * (MAX_RADIUS - MIN_RADIUS); // Add the target to the array newTargets.push({ x, y, radius }); } return newTargets; }; export const getRandomTarget = (currentTarget: number | null, maxTargets: number): number => { let newTarget: number; do { newTarget = Math.floor(Math.random() * maxTargets); } while (newTarget === currentTarget); return newTarget; };