input struct changes
This commit is contained in:
parent
9e9752cc38
commit
4e2af677f6
@ -56,9 +56,9 @@ impl Camera {
|
|||||||
let (dx, dy) = input.mouse_moved;
|
let (dx, dy) = input.mouse_moved;
|
||||||
input.mouse_moved = (0.0, 0.0);
|
input.mouse_moved = (0.0, 0.0);
|
||||||
|
|
||||||
self.rot_x += Deg(dx * input.dots_multiplier / input.dots_per_degree);
|
self.rot_x += Deg(dx * input.sens);
|
||||||
let pitch_lim = 90.0 - 0.0001;
|
let pitch_lim = 90.0 - 0.0001;
|
||||||
let pitch = self.rot_y.0 + (-dy * input.dots_multiplier / input.dots_per_degree);
|
let pitch = self.rot_y.0 + (-dy * input.sens);
|
||||||
self.rot_y = Deg(pitch.clamp(-pitch_lim, pitch_lim));
|
self.rot_y = Deg(pitch.clamp(-pitch_lim, pitch_lim));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -21,12 +21,11 @@ pub struct Input {
|
|||||||
amount_down: f32,
|
amount_down: f32,
|
||||||
mouse_moved: (f32, f32),
|
mouse_moved: (f32, f32),
|
||||||
speed: f32,
|
speed: f32,
|
||||||
dots_multiplier: f32,
|
sens: f32,
|
||||||
dots_per_degree: f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn new(speed: f32, sens: f32) -> Self {
|
pub fn new(speed: f32, dots_multiplier: f32, dots_per_degree: f32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
amount_left: 0.0,
|
amount_left: 0.0,
|
||||||
amount_right: 0.0,
|
amount_right: 0.0,
|
||||||
@ -36,10 +35,7 @@ impl Input {
|
|||||||
amount_down: 0.0,
|
amount_down: 0.0,
|
||||||
mouse_moved: (0.0, 0.0),
|
mouse_moved: (0.0, 0.0),
|
||||||
speed,
|
speed,
|
||||||
dots_multiplier: sens,
|
sens: dots_multiplier / dots_per_degree,
|
||||||
|
|
||||||
// i don't want the sensitivity to be tied to the resolution, though.
|
|
||||||
dots_per_degree: 1920.0 / 360.0,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +109,12 @@ fn real_main() -> Result<(), &'static str> {
|
|||||||
let mut fullscreen = set_fullscreen(false, &(window), &mut(cursor_locked));
|
let mut fullscreen = set_fullscreen(false, &(window), &mut(cursor_locked));
|
||||||
|
|
||||||
let mut state = State::new(window)?;
|
let mut state = State::new(window)?;
|
||||||
let mut input = Input::new(1.0, 8.8 / 100.0);
|
let mut input = Input::new(
|
||||||
|
1.0,
|
||||||
|
8.8 / 100.0,
|
||||||
|
// i don't want the sensitivity to be tied to the resolution, though.
|
||||||
|
1920.0 / 360.0
|
||||||
|
);
|
||||||
|
|
||||||
let mut total_elapsed = 0.0;
|
let mut total_elapsed = 0.0;
|
||||||
let mut timer = Instant::now();
|
let mut timer = Instant::now();
|
||||||
|
Loading…
Reference in New Issue
Block a user