Added drag

master
Mark 2023-12-30 17:51:57 -08:00
parent 2c4db4ebc5
commit 72b4cc8f1b
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
6 changed files with 17 additions and 5 deletions

View File

@ -1,4 +1,4 @@
[engine."plasma"]
thrust = 50
thrust = 100
flare.sprite_texture = "flare::ion"

View File

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

View File

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

View File

@ -24,8 +24,6 @@ fn main() -> Result<()> {
consts::STARFIELD_TEXTURE_NAME.to_owned(),
)?;
println!("{:?}", content.factions);
pollster::block_on(run(content))?;
return Ok(());
}

View File

@ -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 {

View File

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