From a417abf099ab6a46ecbdd20f3dea9ef8b0f67d76 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 30 Dec 2023 11:07:20 -0800 Subject: [PATCH] Fixed ship aspect, added mass --- content/ship.toml | 2 +- crates/content/src/ship.rs | 14 +++++++++----- src/physics/physics.rs | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/content/ship.toml b/content/ship.toml index ae4c0eb..843440a 100644 --- a/content/ship.toml +++ b/content/ship.toml @@ -1,7 +1,7 @@ [ship."Gypsum"] sprite = "ship::gypsum" size = 100 -aspect = 0.47 +mass = 10 hull = 200 engines = [{ x = 0.0, y = -1.05, size = 50.0 }] diff --git a/crates/content/src/ship.rs b/crates/content/src/ship.rs index 4be2ce1..1a17c06 100644 --- a/crates/content/src/ship.rs +++ b/crates/content/src/ship.rs @@ -18,8 +18,8 @@ pub(super) mod syntax { pub engines: Vec, pub guns: Vec, pub hull: f32, + pub mass: f32, pub collision: Collision, - pub aspect: f32, } #[derive(Debug, Deserialize)] @@ -59,6 +59,9 @@ pub struct Ship { /// in terms of game units. pub size: f32, + /// The mass of this ship + pub mass: f32, + /// Engine points on this ship. /// This is where engine flares are drawn. pub engines: Vec, @@ -110,9 +113,6 @@ impl super::Build for Ship { fn build(ship: Self::InputSyntax, ct: &mut Content) -> Result<()> { for (ship_name, ship) in ship { - let size = ship.size; - let aspect = ship.aspect; - let th = match ct.texture_index.get(&ship.sprite) { None => bail!( "In ship `{}`: texture `{}` doesn't exist", @@ -122,10 +122,14 @@ impl super::Build for Ship { Some(t) => *t, }; + let size = ship.size; + let aspect = th.aspect; + ct.ships.push(Self { aspect, - name: ship_name.to_owned(), + name: ship_name, sprite: th, + mass: ship.mass, size, hull: ship.hull, engines: ship diff --git a/src/physics/physics.rs b/src/physics/physics.rs index ade3667..4b04c65 100644 --- a/src/physics/physics.rs +++ b/src/physics/physics.rs @@ -88,7 +88,7 @@ impl Physics { &ct.collision.points[..], &ct.collision.indices[..], ) - .mass(1.0); + .mass(ct.mass); let rb = RigidBodyBuilder::dynamic() .translation(vector![position.x, position.y])