diff options
| author | tom barrett <spalf0@gmail.com> | 2019-02-12 13:20:06 -0600 | 
|---|---|---|
| committer | tom barrett <spalf0@gmail.com> | 2019-02-12 13:20:06 -0600 | 
| commit | 070485e093dc540a5db9650d438cffe3d18d3883 (patch) | |
| tree | a0ab1f42c844b3557c7f17b11f3c7eae334e853d /src/modules/engines.rs | |
| parent | 6a906ce663935e37d6dd79a2e2e31fb07ca7c2af (diff) | |
added constants file, made so items are referred to by an enum, figured better ways than ship_clone
Diffstat (limited to 'src/modules/engines.rs')
| -rw-r--r-- | src/modules/engines.rs | 18 | 
1 files changed, 12 insertions, 6 deletions
diff --git a/src/modules/engines.rs b/src/modules/engines.rs index f319ee5..55b9af9 100644 --- a/src/modules/engines.rs +++ b/src/modules/engines.rs @@ -19,7 +19,13 @@ impl Engines {          acceleration      } -    pub fn give_client_data(&mut self, ship: &Mass, target: Option<&Mass>, data: String) { +    pub fn give_client_data( +        &mut self, +        position: Vector, +        velocity: Vector, +        target: Option<&Mass>, +        data: String, +    ) {          let mut acceleration = Vector::default();          match data.as_bytes() {              b"5\n" => acceleration.a += 0.1, @@ -28,21 +34,21 @@ impl Engines {              b"2\n" => acceleration.b -= 0.1,              b"4\n" => acceleration.c += 0.1,              b"6\n" => acceleration.c -= 0.1, -            b"+\n" => acceleration = ship.velocity.clone() * 0.05, +            b"+\n" => acceleration = velocity * 0.05,              b"-\n" => { -                acceleration = ship.velocity.clone() * -1.05; +                acceleration = velocity * -1.05;              }              b"s\n" => { -                acceleration = ship.velocity.clone() * -1.0; +                acceleration = velocity * -1.0;              }              b"c\n" => {                  if let Some(target) = target { -                    acceleration = target.velocity.clone() - ship.velocity.clone(); +                    acceleration = target.velocity.clone() - velocity;                  }              }              b"t\n" => {                  if let Some(target) = target { -                    acceleration = (target.position.clone() - ship.position.clone()) * 0.01; +                    acceleration = (target.position.clone() - position) * 0.01;                  }              }              _ => (),  | 
