Added drag
parent
2c4db4ebc5
commit
72b4cc8f1b
|
@ -1,4 +1,4 @@
|
|||
[engine."plasma"]
|
||||
|
||||
thrust = 50
|
||||
thrust = 100
|
||||
flare.sprite_texture = "flare::ion"
|
||||
|
|
|
@ -3,6 +3,8 @@ sprite_texture = "ship::gypsum"
|
|||
size = 100
|
||||
mass = 1
|
||||
hull = 200
|
||||
linear_drag = 0.2
|
||||
angular_drag = 0.2
|
||||
|
||||
engines = [{ x = 0.0, y = -1.05, size = 50.0 }]
|
||||
guns = [{ x = 0.0, y = 1 }, { x = 0.1, y = 0.80 }, { x = -0.1, y = 0.80 }]
|
||||
|
|
|
@ -20,6 +20,8 @@ pub(crate) mod syntax {
|
|||
pub hull: f32,
|
||||
pub mass: f32,
|
||||
pub collision: Collision,
|
||||
pub angular_drag: f32,
|
||||
pub linear_drag: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -78,6 +80,12 @@ pub struct Ship {
|
|||
|
||||
/// Remove later
|
||||
pub aspect: f32,
|
||||
|
||||
/// Reduction in angular velocity over time
|
||||
pub angular_drag: f32,
|
||||
|
||||
/// Reduction in velocity over time
|
||||
pub linear_drag: f32,
|
||||
}
|
||||
|
||||
/// Collision shape for this ship
|
||||
|
@ -130,6 +138,8 @@ impl crate::Build for Ship {
|
|||
name: ship_name,
|
||||
sprite_texture: th,
|
||||
mass: ship.mass,
|
||||
angular_drag: ship.angular_drag,
|
||||
linear_drag: ship.linear_drag,
|
||||
size,
|
||||
hull: ship.hull,
|
||||
engines: ship
|
||||
|
|
|
@ -24,8 +24,6 @@ fn main() -> Result<()> {
|
|||
consts::STARFIELD_TEXTURE_NAME.to_owned(),
|
||||
)?;
|
||||
|
||||
println!("{:?}", content.factions);
|
||||
|
||||
pollster::block_on(run(content))?;
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -141,11 +141,11 @@ impl Ship {
|
|||
}
|
||||
|
||||
if self.controls.right {
|
||||
r.apply_torque_impulse(-500.0 * t, true);
|
||||
r.apply_torque_impulse(-1000.0 * t, true);
|
||||
}
|
||||
|
||||
if self.controls.left {
|
||||
r.apply_torque_impulse(500.0 * t, true);
|
||||
r.apply_torque_impulse(1000.0 * t, true);
|
||||
}
|
||||
|
||||
let p = if self.controls.guns {
|
||||
|
|
|
@ -96,6 +96,8 @@ impl Physics {
|
|||
.mass(ct.mass);
|
||||
|
||||
let rb = RigidBodyBuilder::dynamic()
|
||||
.angular_damping(ct.angular_drag)
|
||||
.linear_damping(ct.linear_drag)
|
||||
.translation(vector![position.x, position.y])
|
||||
.can_sleep(false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue