From f27f783501ec0f4820f8e3e92af20f9c7e8dfbce Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Sun, 6 Oct 2024 18:17:57 +0200 Subject: [PATCH] constellation center --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- src/game_state.rs | 7 ++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a40516..ad75e81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,6 +208,16 @@ dependencies = [ "libloading 0.7.4", ] +[[package]] +name = "astraea" +version = "0.1.0" +dependencies = [ + "bevy", + "rand", + "serde", + "serde_json", +] + [[package]] name = "async-broadcast" version = "0.5.1" @@ -305,16 +315,6 @@ dependencies = [ "bevy_internal", ] -[[package]] -name = "bevy-test" -version = "0.1.0" -dependencies = [ - "bevy", - "rand", - "serde", - "serde_json", -] - [[package]] name = "bevy_a11y" version = "0.14.2" diff --git a/Cargo.toml b/Cargo.toml index 0a26a64..8badc97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy-test" +name = "astraea" version = "0.1.0" edition = "2021" diff --git a/src/game_state.rs b/src/game_state.rs index d317694..bc82407 100644 --- a/src/game_state.rs +++ b/src/game_state.rs @@ -362,9 +362,14 @@ fn choose_constellation( let target_index = rng.next_u32().rem_euclid(4) as usize; let target_constellation = &constellations[target_index]; + + let mut mean_pos = Vec3::ZERO; + for star in target_constellation.stars.clone() { + mean_pos += celestial_to_cartesian(star.rah, star.dec) + } let target_rotation = Quat::from_rotation_arc( Vec3::Z, - -celestial_to_cartesian(target_constellation.rah, target_constellation.dec), + -mean_pos*(1.0/target_constellation.stars.len() as f32), ); player.target_rotation = Some(target_rotation);