Replaced Degrees and Radians with a single Angle type
[kaka/rust-sdl-test.git] / src / core / controller.rs
index 54dae94..3cbe391 100644 (file)
@@ -1,6 +1,5 @@
-use common::Point;
+use common::{Angle, Point};
 use {hashmap, point};
-use common::Radians;
 use sdl2::HapticSubsystem;
 use sdl2::JoystickSubsystem;
 use sdl2::event::Event;
@@ -67,7 +66,7 @@ pub struct Stick {
     idy: u8,
     pub x: f32,
     pub y: f32,
-    pub a: Radians,
+    pub a: Angle,
 }
 
 impl Stick {
@@ -80,7 +79,7 @@ impl Stick {
            Ok(val) => val as f32 / 32768.0,
            Err(_) => panic!("invalid y axis {}", self.idy),
        };
-       self.a = Radians(self.y.atan2(self.x) as f64);
+       self.a = point!(self.x as f64, self.y as f64).to_angle();
     }
 
     #[inline(always)] #[allow(dead_code)] pub fn up(&self) -> bool { self.y < -0.99 }