Fixed ship aspect, added mass
parent
3c62907fb6
commit
a417abf099
|
@ -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 }]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue