diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 14:33:23 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 14:33:23 -0700 |
| commit | da45c5a7dbb017c8e579d0ab66a2259a70b28f40 (patch) | |
| tree | 938c0be6bd6b938cb8788456ce759b784ee74f5c /src/camera.rs | |
| parent | c4c26f03e3eb18a76f9c2756076030dc52a667fa (diff) | |
input manager
Diffstat (limited to 'src/camera.rs')
| -rw-r--r-- | src/camera.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/camera.rs b/src/camera.rs index 13c5ec9..0fe9f22 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,4 +1,7 @@ -use crate::{Input, config::CAMERA_MOVEMENT_SPEED}; +use crate::{ + config::CAMERA_MOVEMENT_SPEED, + input::{Input, InputManager}, +}; #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] @@ -28,18 +31,18 @@ impl Camera { (xl, xu, yl, yu) } - pub fn handle_camera_input(&mut self, input: &Input, delta_time: f32) { + pub fn handle_camera_input(&mut self, input_manager: &InputManager, delta_time: f32) { // wasd movement - let x: f32 = if input.is_left_pressed { + let x: f32 = if input_manager.held(Input::Left) { -1.0 - } else if input.is_right_pressed { + } else if input_manager.held(Input::Right) { 1.0 } else { 0.0 }; - let y: f32 = if input.is_down_pressed { + let y: f32 = if input_manager.held(Input::Down) { 1.0 - } else if input.is_up_pressed { + } else if input_manager.held(Input::Up) { -1.0 } else { 0.0 |
