screen space boid spawn

This commit is contained in:
Zynh Ludwig 2024-09-03 01:19:37 -07:00
parent 6938bcd2d0
commit f7c548074d

View file

@ -72,18 +72,25 @@ fn setup(
mut commands: Commands,
mut materials: ResMut<Assets<ColorMaterial>>,
boid_mesh: Res<BoidMesh>,
windows: Query<&Window>,
) {
let window = windows.get_single().unwrap();
let half_width = window.resolution.width() / 4.;
let half_height = window.resolution.height() / 2.;
let boid_color = materials.add(Color::from(tailwind::NEUTRAL_50));
let mut small_rng = rand::rngs::SmallRng::from_entropy();
let lower_bound = -100.;
let upper_bound = 100.;
let lower_width = -half_width;
let upper_width = half_width;
let lower_height = -half_height;
let upper_height = half_height;
for i in 0..1000 {
use std::f32::consts::TAU;
let x = small_rng.gen_range(lower_bound..=upper_bound);
let y = small_rng.gen_range(lower_bound..=upper_bound);
let x = small_rng.gen_range(lower_width..=upper_width);
let y = small_rng.gen_range(lower_height..=upper_height);
let angle = small_rng.gen_range(-TAU..=TAU);