From 5d4ec3c77c7fd3064db51a17ee2482223d693cb0 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 18 Mar 2024 04:00:41 +0100 Subject: [PATCH] better distribution of asteroids --- src/world.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/world.rs b/src/world.rs index cae6e29..d6cef09 100644 --- a/src/world.rs +++ b/src/world.rs @@ -105,25 +105,29 @@ pub fn setup( }); // Add a bunch of asteriods - let sphere_radius = 10.0; + let sphere_radius = 100.0; let sphere_handle = meshes.add(Sphere::new(sphere_radius)); let asteroid_color_handle = materials.add(StandardMaterial { - base_color: Color::rgb(0.4, 0.3, 0.1), + base_color: Color::rgb(0.25, 0.2, 0.2), perceptual_roughness: 1.0, ..default() }); - for i in -20..20 { - for j in -20..20 { - for k in -20..20 { + for i in -12..12 { + for j in -13..13 { + for k in -14..14 { + let offset = 500.0; + let dist = 9000.0; + let wobble = 3000.0; + let (i, j, k) = (i as f32, j as f32, k as f32); commands.spawn(( actor::Actor::default(), PbrBundle { mesh: sphere_handle.clone(), material: asteroid_color_handle.clone(), transform: Transform::from_xyz( - 200.0 * i as f32, - 400.0 * j as f32, - 250.0 * k as f32, + offset + dist * i + wobble * (j+k/PI).sin() * (k+j/PI).cos(), + offset + dist * j + wobble * (k+i/PI).sin() * (i+k/PI).cos(), + offset + dist * k + wobble * (i+j/PI).sin() * (j+i/PI).cos(), ), ..default() }