better distribution of asteroids

This commit is contained in:
yuni 2024-03-18 04:00:41 +01:00
parent 1e003adeeb
commit 5d4ec3c77c

View file

@ -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()
}