pub fn update(&mut self, input_manager: &mut InputManager, delta: &f32) {
        // sets a base speed for the camera
        let camera_speed: f32 = CAMERA_SPEED * delta;

        // sets a base rotation speed for the camera
        let rotation_speed: f32 = CAMERA_ROT * delta;

        // polls the input checker to check for keys
        if input_manager.poll_key(VirtualKeyCode::W) {
            // calculates the y component of the movement
            let y_component = Rad::sin(Rad(self.rotation.x)) * camera_speed;

            // gets the xz component of the movement
            let xz_component = Rad::cos(Rad(self.rotation.x)) * camera_speed;

            // based on the xz components, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y)) * xz_component;
            let z_component = Rad::cos(Rad(self.rotation.y)) * xz_component;

            // translates the cam
            self.translate(Vector3::new(x_component, -y_component, -z_component));
        }

        if input_manager.poll_key(VirtualKeyCode::S) {
            // calculates the y component of the movement
            let y_component = Rad::sin(Rad(self.rotation.x)) * camera_speed;

            // gets the xz component of the movement
            let xz_component = Rad::cos(Rad(self.rotation.x)) * camera_speed;

            // based on the xz components, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y)) * xz_component;
            let z_component = Rad::cos(Rad(self.rotation.y)) * xz_component;

            // translates the cam
            self.translate(Vector3::new(-x_component, y_component, z_component));
        }

        if input_manager.poll_key(VirtualKeyCode::A) {
            // based on the camera_speed, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            let z_component = Rad::cos(Rad(self.rotation.y + PI/2.0)) * camera_speed;

            // translates the cam
            self.translate(Vector3::new(-x_component, 0.0, z_component));
        }

        if input_manager.poll_key(VirtualKeyCode::D) {
            // based on the camera_speed, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            let z_component = Rad::cos(Rad(self.rotation.y + PI/2.0)) * camera_speed;

            // translates the cam
            self.translate(Vector3::new(x_component, 0.0, -z_component));
        }

        // rotates the camera using the arrow keys
        if input_manager.poll_key(VirtualKeyCode::Left) {
            self.rotate(Vector3::new(0.0, -rotation_speed, 0.0));
        }

        if input_manager.poll_key(VirtualKeyCode::Right) {
            self.rotate(Vector3::new(0.0, rotation_speed, 0.0));
        }

        if input_manager.poll_key(VirtualKeyCode::Up) {
            self.rotate(Vector3::new(-rotation_speed, 0.0, 0.0));
        }

        if input_manager.poll_key(VirtualKeyCode::Down) {
            self.rotate(Vector3::new(rotation_speed, 0.0, 0.0));
        }
    }
// updates the camera based on the input manager
updates the camera based on the input manager
updates the camera based on the input manager
pub fn update(&mut self, input_manager: &mut InputManager, delta: &f32) {
        // sets a base speed for the camera
        let camera_speed: f32 = CAMERA_SPEED * delta;
        // sets a base rotation speed for the camera
        let rotation_speed: f32 = CAMERA_ROT * delta;
        // polls the input checker to check for keys
        if input_manager.poll_key(VirtualKeyCode::W) {
            // calculates the y component of the movement
            let y_component = Rad::sin(Rad(self.rotation.x)) * camera_speed;
            // gets the xz component of the movement
            let xz_component = Rad::cos(Rad(self.rotation.x)) * camera_speed;
            // based on the xz components, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y)) * xz_component;
            let z_component = Rad::cos(Rad(self.rotation.y)) * xz_component;
            // translates the cam
            self.translate(Vector3::new(x_component, -y_component, -z_component));
        }
        if input_manager.poll_key(VirtualKeyCode::S) {
            // calculates the y component of the movement
            let y_component = Rad::sin(Rad(self.rotation.x)) * camera_speed;
            // gets the xz component of the movement
            let xz_component = Rad::cos(Rad(self.rotation.x)) * camera_speed;
            // based on the xz components, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y)) * xz_component;
            let z_component = Rad::cos(Rad(self.rotation.y)) * xz_component;
            // translates the cam
            self.translate(Vector3::new(-x_component, y_component, z_component));
        }
        if input_manager.poll_key(VirtualKeyCode::A) {
            // based on the camera_speed, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            let z_component = Rad::cos(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            // translates the cam
            self.translate(Vector3::new(-x_component, 0.0, z_component));
        }
        if input_manager.poll_key(VirtualKeyCode::D) {
            // based on the camera_speed, gets the x and z movement
            let x_component = Rad::sin(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            let z_component = Rad::cos(Rad(self.rotation.y + PI/2.0)) * camera_speed;
            // translates the cam
            self.translate(Vector3::new(x_component, 0.0, -z_component));
        }
        // rotates the camera using the arrow keys
        if input_manager.poll_key(VirtualKeyCode::Left) {
            self.rotate(Vector3::new(0.0, -rotation_speed, 0.0));
        }
        if input_manager.poll_key(VirtualKeyCode::Right) {
            self.rotate(Vector3::new(0.0, rotation_speed, 0.0));
        }
        if input_manager.poll_key(VirtualKeyCode::Up) {
            self.rotate(Vector3::new(-rotation_speed, 0.0, 0.0));
        }
        if input_manager.poll_key(VirtualKeyCode::Down) {
            self.rotate(Vector3::new(rotation_speed, 0.0, 0.0));
        }
    }
pub fn update ( & mut self , input_manager : & mut InputManager , delta : & f32 ) { // sets a base speed for the camera let camera_speed : f32 = CAMERA_SPEED * delta ; // sets a base rotation speed for the camera let rotation_speed : f32 = CAMERA_ROT * delta ; // polls the input checker to check for keys if input_manager . poll_key ( VirtualKeyCode :: W ) { // calculates the y component of the movement let y_component = Rad :: sin ( Rad ( self . rotation . x ) ) * camera_speed ; // gets the xz component of the movement let xz_component = Rad :: cos ( Rad ( self . rotation . x ) ) * camera_speed ; // based on the xz components, gets the x and z movement let x_component = Rad :: sin ( Rad ( self . rotation . y ) ) * xz_component ; let z_component = Rad :: cos ( Rad ( self . rotation . y ) ) * xz_component ; // translates the cam self . translate ( Vector3 :: new ( x_component , - y_component , - z_component ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: S ) { // calculates the y component of the movement let y_component = Rad :: sin ( Rad ( self . rotation . x ) ) * camera_speed ; // gets the xz component of the movement let xz_component = Rad :: cos ( Rad ( self . rotation . x ) ) * camera_speed ; // based on the xz components, gets the x and z movement let x_component = Rad :: sin ( Rad ( self . rotation . y ) ) * xz_component ; let z_component = Rad :: cos ( Rad ( self . rotation . y ) ) * xz_component ; // translates the cam self . translate ( Vector3 :: new ( - x_component , y_component , z_component ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: A ) { // based on the camera_speed, gets the x and z movement let x_component = Rad :: sin ( Rad ( self . rotation . y + PI / 2.0 ) ) * camera_speed ; let z_component = Rad :: cos ( Rad ( self . rotation . y + PI / 2.0 ) ) * camera_speed ; // translates the cam self . translate ( Vector3 :: new ( - x_component , 0.0 , z_component ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: D ) { // based on the camera_speed, gets the x and z movement let x_component = Rad :: sin ( Rad ( self . rotation . y + PI / 2.0 ) ) * camera_speed ; let z_component = Rad :: cos ( Rad ( self . rotation . y + PI / 2.0 ) ) * camera_speed ; // translates the cam self . translate ( Vector3 :: new ( x_component , 0.0 , - z_component ) ) ; } // rotates the camera using the arrow keys if input_manager . poll_key ( VirtualKeyCode :: Left ) { self . rotate ( Vector3 :: new ( 0.0 , - rotation_speed , 0.0 ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: Right ) { self . rotate ( Vector3 :: new ( 0.0 , rotation_speed , 0.0 ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: Up ) { self . rotate ( Vector3 :: new ( - rotation_speed , 0.0 , 0.0 ) ) ; } if input_manager . poll_key ( VirtualKeyCode :: Down ) { self . rotate ( Vector3 :: new ( rotation_speed , 0.0 , 0.0 ) ) ; } }
updates the camera based on the input manager
updates the camera based on the input manager
&mut self
input_manager
&mut InputManager
delta
&f32
&mut self
input_manager
&mut InputManager
delta
&f32