X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcore%2Fcontroller.rs;fp=src%2Fcore%2Fcontroller.rs;h=3cbe39153af5ab2d3fc6d866d43266745d21572e;hb=4074267844733949556af129550dfc42fc81da76;hp=54dae94312b07938c385e81106a0c6f3cfc81320;hpb=0d75b79ec38b321835c2f3984252f27ff271f8b4;p=kaka%2Frust-sdl-test.git diff --git a/src/core/controller.rs b/src/core/controller.rs index 54dae94..3cbe391 100644 --- a/src/core/controller.rs +++ b/src/core/controller.rs @@ -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 }