From 6a6b53d0c0ca3b179754fdd455219e6789679d12 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 18 Mar 2024 04:39:26 +0100 Subject: [PATCH] cleanup --- src/camera.rs | 85 +++++++-------------------------------------- src/hud.rs | 2 +- src/main.rs | 4 +-- src/settings.rs | 26 ++++++++++++-- src/world.rs | 91 ++++++++++++++++++++++++++----------------------- 5 files changed, 89 insertions(+), 119 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index db104a2..48ff140 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use bevy::input::mouse::MouseMotion; use bevy::window::PrimaryWindow; -use std::{f32::consts::*, fmt}; +use std::f32::consts::*; use crate::{settings, audio}; pub struct CameraControllerPlugin; @@ -12,9 +12,9 @@ impl Plugin for CameraControllerPlugin { } } -/// Based on Valorant's default sensitivity, not entirely sure why it is exactly 1.0 / 180.0, -/// but I'm guessing it is a misunderstanding between degrees/radians and then sticking with -/// it because it felt nice. +// Based on Valorant's default sensitivity, not entirely sure why it is exactly 1.0 / 180.0, +// but I'm guessing it is a misunderstanding between degrees/radians and then sticking with +// it because it felt nice. pub const RADIANS_PER_DOT: f32 = 1.0 / 180.0; #[derive(Component)] @@ -22,15 +22,6 @@ pub struct CameraController { pub enabled: bool, pub initialized: bool, pub sensitivity: f32, - pub key_forward: KeyCode, - pub key_back: KeyCode, - pub key_left: KeyCode, - pub key_right: KeyCode, - pub key_up: KeyCode, - pub key_down: KeyCode, - pub key_run: KeyCode, - pub key_stop: KeyCode, - pub mouse_key_cursor_grab: MouseButton, pub move_speed: f32, pub friction: f32, pub pitch: f32, @@ -44,15 +35,6 @@ impl Default for CameraController { enabled: true, initialized: false, sensitivity: 0.5, - key_forward: KeyCode::KeyW, - key_back: KeyCode::KeyS, - key_left: KeyCode::KeyA, - key_right: KeyCode::KeyD, - key_up: KeyCode::ShiftLeft, - key_down: KeyCode::ControlLeft, - key_run: KeyCode::KeyR, - key_stop: KeyCode::Space, - mouse_key_cursor_grab: MouseButton::Left, move_speed: 1.0, friction: 0.1, pitch: 1.0, // pitch=0/yaw=0 -> face sun @@ -62,41 +44,14 @@ impl Default for CameraController { } } -impl fmt::Display for CameraController { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - " -Freecam Controls: - Mouse\t- Move camera orientation - {:?}\t- Hold to grab cursor - {:?} & {:?}\t- Fly forward & backwards - {:?} & {:?}\t- Fly sideways left & right - {:?} & {:?}\t- Fly up & down - {:?}\t- Fly faster while held", - self.mouse_key_cursor_grab, - self.key_forward, - self.key_back, - self.key_left, - self.key_right, - self.key_up, - self.key_down, - self.key_run, - ) - } -} - #[allow(clippy::too_many_arguments)] fn run_camera_controller( time: Res