Fixed ship aspect, added mass

master
Mark 2023-12-30 11:07:20 -08:00
parent 3c62907fb6
commit a417abf099
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
3 changed files with 11 additions and 7 deletions

View File

@ -1,7 +1,7 @@
[ship."Gypsum"] [ship."Gypsum"]
sprite = "ship::gypsum" sprite = "ship::gypsum"
size = 100 size = 100
aspect = 0.47 mass = 10
hull = 200 hull = 200
engines = [{ x = 0.0, y = -1.05, size = 50.0 }] engines = [{ x = 0.0, y = -1.05, size = 50.0 }]

View File

@ -18,8 +18,8 @@ pub(super) mod syntax {
pub engines: Vec<Engine>, pub engines: Vec<Engine>,
pub guns: Vec<Gun>, pub guns: Vec<Gun>,
pub hull: f32, pub hull: f32,
pub mass: f32,
pub collision: Collision, pub collision: Collision,
pub aspect: f32,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
@ -59,6 +59,9 @@ pub struct Ship {
/// in terms of game units. /// in terms of game units.
pub size: f32, pub size: f32,
/// The mass of this ship
pub mass: f32,
/// Engine points on this ship. /// Engine points on this ship.
/// This is where engine flares are drawn. /// This is where engine flares are drawn.
pub engines: Vec<EnginePoint>, pub engines: Vec<EnginePoint>,
@ -110,9 +113,6 @@ impl super::Build for Ship {
fn build(ship: Self::InputSyntax, ct: &mut Content) -> Result<()> { fn build(ship: Self::InputSyntax, ct: &mut Content) -> Result<()> {
for (ship_name, ship) in ship { for (ship_name, ship) in ship {
let size = ship.size;
let aspect = ship.aspect;
let th = match ct.texture_index.get(&ship.sprite) { let th = match ct.texture_index.get(&ship.sprite) {
None => bail!( None => bail!(
"In ship `{}`: texture `{}` doesn't exist", "In ship `{}`: texture `{}` doesn't exist",
@ -122,10 +122,14 @@ impl super::Build for Ship {
Some(t) => *t, Some(t) => *t,
}; };
let size = ship.size;
let aspect = th.aspect;
ct.ships.push(Self { ct.ships.push(Self {
aspect, aspect,
name: ship_name.to_owned(), name: ship_name,
sprite: th, sprite: th,
mass: ship.mass,
size, size,
hull: ship.hull, hull: ship.hull,
engines: ship engines: ship

View File

@ -88,7 +88,7 @@ impl Physics {
&ct.collision.points[..], &ct.collision.points[..],
&ct.collision.indices[..], &ct.collision.indices[..],
) )
.mass(1.0); .mass(ct.mass);
let rb = RigidBodyBuilder::dynamic() let rb = RigidBodyBuilder::dynamic()
.translation(vector![position.x, position.y]) .translation(vector![position.x, position.y])