random pos?

This commit is contained in:
Zynh0722 2024-02-15 02:44:49 -08:00
parent c113fdaf92
commit da25ffb0bf

View file

@ -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