screen space boid spawn
This commit is contained in:
parent
6938bcd2d0
commit
f7c548074d
1 changed files with 11 additions and 4 deletions
15
src/main.rs
15
src/main.rs
|
@ -72,18 +72,25 @@ fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
boid_mesh: Res<BoidMesh>,
|
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 boid_color = materials.add(Color::from(tailwind::NEUTRAL_50));
|
||||||
|
|
||||||
let mut small_rng = rand::rngs::SmallRng::from_entropy();
|
let mut small_rng = rand::rngs::SmallRng::from_entropy();
|
||||||
let lower_bound = -100.;
|
let lower_width = -half_width;
|
||||||
let upper_bound = 100.;
|
let upper_width = half_width;
|
||||||
|
let lower_height = -half_height;
|
||||||
|
let upper_height = half_height;
|
||||||
|
|
||||||
for i in 0..1000 {
|
for i in 0..1000 {
|
||||||
use std::f32::consts::TAU;
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
let x = 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_bound..=upper_bound);
|
let y = small_rng.gen_range(lower_height..=upper_height);
|
||||||
|
|
||||||
let angle = small_rng.gen_range(-TAU..=TAU);
|
let angle = small_rng.gen_range(-TAU..=TAU);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue