initialize method
Inicializa el sistema con N boids
Implementation
void initialize({
required int count,
required double canvasWidth,
required double canvasHeight,
}) {
AppConfig.logger.d('🎯 ENGINE INIT: canvasWidth=$canvasWidth, canvasHeight=$canvasHeight');
width = canvasWidth;
height = canvasHeight;
_gridCellSize = (perceptionRadius * 1.1).toInt().clamp(35, 70);
boids.clear();
_spatialGrid = {};
for (int i = 0; i < count; i++) {
boids.add(Boid(
x: _random.nextDouble() * width,
y: _random.nextDouble() * height,
z: _random.nextDouble(), // Profundidad aleatoria
vx: (_random.nextDouble() - 0.5) * maxSpeed,
vy: (_random.nextDouble() - 0.5) * maxSpeed,
vz: (_random.nextDouble() - 0.5) * 0.015,
size: 2.5 + _random.nextDouble() * 2.0,
color: colorPalette[_random.nextInt(colorPalette.length)],
energy: 0.5 + _random.nextDouble() * 0.5,
));
}
AppConfig.logger.d('🎯 ENGINE AFTER: width=$width, height=$height');
}