use bevy::prelude::*;
use bevy_pancam::{PanCam, PanCamPlugin};
use rand::random;
fn main() {
App::new()
.add_plugins((DefaultPlugins, PanCamPlugin))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((Camera2d, PanCam::default()));
let n = 20;
let spacing = 50.;
let offset = spacing * n as f32 / 2.;
let custom_size = Some(Vec2::new(spacing, spacing));
for x in 0..n {
for y in 0..n {
let x = x as f32 * spacing - offset;
let y = y as f32 * spacing - offset;
let color = Color::hsl(240., random::<f32>() * 0.3, random::<f32>() * 0.3);
commands.spawn((
Sprite {
color,
custom_size,
..default()
},
Transform::from_xyz(x, y, 0.),
));
}
}
}