Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use .signum() instead of if-else
[kaka/rust-sdl-test.git]
/
src
/
core
/
controller.rs
diff --git
a/src/core/controller.rs
b/src/core/controller.rs
index
54dae94
..
de91928
100644
(file)
--- a/
src/core/controller.rs
+++ b/
src/core/controller.rs
@@
-1,6
+1,5
@@
-use
common::Point
;
+use
geometry::{Angle, Point}
;
use {hashmap, point};
use {hashmap, point};
-use common::Radians;
use sdl2::HapticSubsystem;
use sdl2::JoystickSubsystem;
use sdl2::event::Event;
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,
idy: u8,
pub x: f32,
pub y: f32,
- pub a:
Radians
,
+ pub a:
Angle
,
}
impl Stick {
}
impl Stick {
@@
-80,7
+79,7
@@
impl Stick {
Ok(val) => val as f32 / 32768.0,
Err(_) => panic!("invalid y axis {}", self.idy),
};
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 }
}
#[inline(always)] #[allow(dead_code)] pub fn up(&self) -> bool { self.y < -0.99 }