diff --git a/src/fly_controller.rs b/src/fly_controller.rs index 09921a7..51f4285 100644 --- a/src/fly_controller.rs +++ b/src/fly_controller.rs @@ -1,6 +1,6 @@ -use glam::{Mat4, EulerRot, Quat}; +use glam::{Vec3, Mat4, EulerRot, Quat}; use shipyard::{Component, View, ViewMut, IntoIter, UniqueView}; -use crate::{transform::Transform, input::Inputs}; +use crate::{transform::Transform, input::Inputs, settings::GameSettings}; #[derive(Component)] pub struct FlyController; @@ -8,11 +8,13 @@ pub struct FlyController; pub fn update_controllers( controllers: View, mut transforms: ViewMut, - inputs: UniqueView + inputs: UniqueView, + settings: UniqueView, ) { for (_, mut transform) in (&controllers, &mut transforms).iter() { let (scale, mut rotation, translation) = transform.0.to_scale_rotation_translation(); - rotation *= Quat::from_euler(EulerRot::XYZ, 0., 0.001, 0.); + let look = inputs.look * settings.mouse_sensitivity * -1.; + rotation *= Quat::from_euler(EulerRot::YXZ, look.x, look.y, 0.); transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation); } } diff --git a/src/input.rs b/src/input.rs index eb5031e..498a0b8 100644 --- a/src/input.rs +++ b/src/input.rs @@ -38,7 +38,7 @@ pub fn process_events( } }, DeviceEvent::Button { button, state } => { - println!("Button {button} {state:?}"); + //log::debug!("Button {button} {state:?}"); }, _ => () } diff --git a/src/settings.rs b/src/settings.rs index 2ad524c..e62bf97 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -4,11 +4,13 @@ use shipyard::Unique; pub struct GameSettings { //there's a 1 chunk border of loaded but invisible around this pub render_distance: u8, + pub mouse_sensitivity: f32, } impl Default for GameSettings { fn default() -> Self { Self { - render_distance: 2 + render_distance: 2, + mouse_sensitivity: 0.01, } } }