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"]
sprite = "ship::gypsum"
size = 100
aspect = 0.47
mass = 10
hull = 200
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 guns: Vec<Gun>,
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<EnginePoint>,
@ -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

View File

@ -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])