From 221434eafec46c6e1974d40f17893fee379cead8 Mon Sep 17 00:00:00 2001 From: "stvnliu@homelab" Date: Thu, 20 Mar 2025 15:20:36 +0200 Subject: refactor: updated project structure, set up PLAN --- src/PLAN.md | 17 +++++ src/controllable.rs | 5 ++ src/controllable/player.rs | 10 +++ src/lunar.rs | 13 ++++ src/lunar/structs.rs | 14 ++++ src/lunar/systems.rs | 46 +++++++++++++ src/main.rs | 149 ++++++++++------------------------------ src/roam_physics.rs | 0 src/roam_physics/gravitation.rs | 0 src/setup.rs | 26 +++++++ 10 files changed, 169 insertions(+), 111 deletions(-) create mode 100644 src/PLAN.md create mode 100644 src/controllable.rs create mode 100644 src/controllable/player.rs create mode 100644 src/lunar.rs create mode 100644 src/lunar/structs.rs create mode 100644 src/lunar/systems.rs create mode 100644 src/roam_physics.rs create mode 100644 src/roam_physics/gravitation.rs create mode 100644 src/setup.rs (limited to 'src') diff --git a/src/PLAN.md b/src/PLAN.md new file mode 100644 index 0000000..a6b375a --- /dev/null +++ b/src/PLAN.md @@ -0,0 +1,17 @@ +# Master plan +## UI +UI will be designed later on. +## Stage 1 +The premise of the rescue mission: +- You are the lead of a multinational effort to land a man on the moon. +- In Year 20xx, you succeeded, but because you used inches instead of metres, a catastrophic error caused astronaut X to become stranded. +- Desperate to bring back X, you set out to recover him with a spacecraft in 2030. + +- A rocket is constructed, powerful enough to carry you to the moon. +- Due to planetary physics, the rocket cannot reach the moon by its own propulsion, you will need to accelerate using the planet's gravitational pull. + +- After increasing your orbital radius enough to reach Moon, you land to begin a search. + +## The search - stage 2 + +## Leaving, and landing \ No newline at end of file diff --git a/src/controllable.rs b/src/controllable.rs new file mode 100644 index 0000000..feaeced --- /dev/null +++ b/src/controllable.rs @@ -0,0 +1,5 @@ +mod player; +pub use player::{ + ControlledObject, + Player, +}; \ No newline at end of file diff --git a/src/controllable/player.rs b/src/controllable/player.rs new file mode 100644 index 0000000..a87ef9d --- /dev/null +++ b/src/controllable/player.rs @@ -0,0 +1,10 @@ +use bevy::{ecs::component::Component, text::Text2d}; +#[derive(Component)] + +pub struct Player { + // pub display_name: Text2d, + pub mass_kg: f32, +} +pub struct ControlledObject { + +} \ No newline at end of file diff --git a/src/lunar.rs b/src/lunar.rs new file mode 100644 index 0000000..6b853d0 --- /dev/null +++ b/src/lunar.rs @@ -0,0 +1,13 @@ +mod structs; +mod systems; + +pub use { + structs::{ + DestPlanet, + LunarOrbitalData + }, + systems::{ + setup_moon, + update_lunar_transform, + }, +}; \ No newline at end of file diff --git a/src/lunar/structs.rs b/src/lunar/structs.rs new file mode 100644 index 0000000..61b3a66 --- /dev/null +++ b/src/lunar/structs.rs @@ -0,0 +1,14 @@ +use bevy::ecs::component::Component; + +#[derive(Component)] +pub struct DestPlanet { + // pub display_name: String, + pub planet_mass_kg: f32, + pub radius: f32, +} +#[derive(Component)] +pub struct LunarOrbitalData { + pub period: f32, + pub orbital_velocity: f32, + pub orbital_radius: f32, +} \ No newline at end of file diff --git a/src/lunar/systems.rs b/src/lunar/systems.rs new file mode 100644 index 0000000..4cdebdc --- /dev/null +++ b/src/lunar/systems.rs @@ -0,0 +1,46 @@ +use bevy::prelude::*; +use avian2d::prelude::*; +use super::DestPlanet; +use super::LunarOrbitalData; +pub fn lunar_period_to_vec(angular_pos: f32, radius: f32) -> Vec2 { + let x = radius * f32::cos(angular_pos); + let y = radius * f32::sin(angular_pos); + Vec2 { x, y } +} +pub fn update_lunar_transform( + time: Res