input struct changes

This commit is contained in:
aiden 2023-05-15 09:42:30 +01:00
parent 9e9752cc38
commit 4e2af677f6
Signed by: aiden
GPG Key ID: EFA9C74AEBF806E0
2 changed files with 11 additions and 10 deletions

@ -56,9 +56,9 @@ impl Camera {
let (dx, dy) = input.mouse_moved;
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 = 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));
}
}

@ -21,12 +21,11 @@ pub struct Input {
amount_down: f32,
mouse_moved: (f32, f32),
speed: f32,
dots_multiplier: f32,
dots_per_degree: f32,
sens: f32,
}
impl Input {
pub fn new(speed: f32, sens: f32) -> Self {
pub fn new(speed: f32, dots_multiplier: f32, dots_per_degree: f32) -> Self {
Self {
amount_left: 0.0,
amount_right: 0.0,
@ -36,10 +35,7 @@ impl Input {
amount_down: 0.0,
mouse_moved: (0.0, 0.0),
speed,
dots_multiplier: sens,
// i don't want the sensitivity to be tied to the resolution, though.
dots_per_degree: 1920.0 / 360.0,
sens: dots_multiplier / dots_per_degree,
}
}
@ -113,7 +109,12 @@ fn real_main() -> Result<(), &'static str> {
let mut fullscreen = set_fullscreen(false, &(window), &mut(cursor_locked));
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 timer = Instant::now();