From da25ffb0bfb08b744e97a926b577b499ad80c50e Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Thu, 15 Feb 2024 02:44:49 -0800 Subject: [PATCH] random pos? --- src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3c80352..e2522a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,10 +21,17 @@ fn model(app: &App) -> Model { .build() .unwrap(); - Model { - _window, - particles: Vec::new(), + let boundary = app.window_rect(); + let mut particles = Vec::new(); + + for _ in 0..100 { + let x = random_range(boundary.left(), boundary.right()); + let y = random_range(boundary.top(), boundary.bottom()); + let particle = Particle::new(Vec2::new(x, y)); + particles.push(particle); } + + Model { _window, particles } } // Handle events related to the window and update the model if necessary