From c0103ec2475b7359ece2ddddcccb65af0ead6e60 Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Tue, 8 Oct 2024 17:25:04 +0200 Subject: [PATCH] added right click rot --- src/explo_state.rs | 75 ++++++++++++++++++++++++++++++++++++++++++---- src/game_state.rs | 2 +- src/main.rs | 7 +++-- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/explo_state.rs b/src/explo_state.rs index 1e4814a..ee5cf99 100644 --- a/src/explo_state.rs +++ b/src/explo_state.rs @@ -13,7 +13,8 @@ use crate::MainGame; use crate::spawn_cons_lines; use crate::CONS_VIEW_RADIUS; -use crate::MOUSE_SPEED; +use crate::MOVE_SPEED; +use crate::ROT_SPEED; #[derive(Component)] pub struct InfoLabel; @@ -75,7 +76,7 @@ pub fn player_mouse_move ( let local_transform = &global_transform.compute_transform(); if !buttons.pressed(MouseButton::Left) { - player.dragging_pos = None; + player.l_drag_pos = None; return; } @@ -85,8 +86,8 @@ pub fn player_mouse_move ( return; }; - let Some(old_cursor) = player.dragging_pos else { - player.dragging_pos = Some(new_cursor); + let Some(old_cursor) = player.l_drag_pos else { + player.l_drag_pos = Some(new_cursor); return; }; @@ -105,7 +106,69 @@ pub fn player_mouse_move ( let delta_rotation = rotate_to_align(new_ray, old_ray); player.target_rotation = Some(delta_rotation * local_transform.rotation ); - player.dragging_pos = Some(new_cursor); + player.l_drag_pos = Some(new_cursor); +} + +pub fn player_mouse_rotate ( + buttons: Res>, + mut player_query: Query<(&mut Player, &mut GlobalTransform)>, + window_query: Query<&Window, With>, + ui_query: Query<&Interaction, With