Fix movement inputs when holding shift #7

Open
aidan9382 wants to merge 1 commits from aidan9382/strafe-client:master into master
Member

minor fix but its very annoying since it also breaks releasing keys

minor fix but its very annoying since it also breaks releasing keys
aidan9382 added 1 commit 2024-10-14 19:23:44 +00:00
Owner

This code allocates a new string, which the goal of .as_str() was to avoid that. Please don't use master branch for pull requests, as I can't add any commits!

This code allocates a new string, which the goal of .as_str() was to avoid that. Please don't use master branch for pull requests, as I can't add any commits!
Owner

Here is an alternative option

						if let Some(input_instruction)=match keycode{
							winit::keyboard::Key::Named(winit::keyboard::NamedKey::Space)=>Some(InputInstruction::Jump(s)),
							winit::keyboard::Key::Character(key)=>match key.as_str(){
								"W"|"w"=>Some(InputInstruction::MoveForward(s)),
								"A"|"a"=>Some(InputInstruction::MoveLeft(s)),
								"S"|"s"=>Some(InputInstruction::MoveBack(s)),
								"D"|"d"=>Some(InputInstruction::MoveRight(s)),
								"E"|"e"=>Some(InputInstruction::MoveUp(s)),
								"Q"|"q"=>Some(InputInstruction::MoveDown(s)),
								"Z"|"z"=>Some(InputInstruction::Zoom(s)),
								"R"|"r"=>if s{
									//mouse needs to be reset since the position is absolute
									self.mouse=strafesnet_common::mouse::MouseState::default();
									Some(InputInstruction::ResetAndRestart)
								}else{None},
								"F"|"f"=>if s{Some(InputInstruction::PracticeFly)}else{None},
								_=>None,
							},
							_=>None,
						}
Here is an alternative option ```rust if let Some(input_instruction)=match keycode{ winit::keyboard::Key::Named(winit::keyboard::NamedKey::Space)=>Some(InputInstruction::Jump(s)), winit::keyboard::Key::Character(key)=>match key.as_str(){ "W"|"w"=>Some(InputInstruction::MoveForward(s)), "A"|"a"=>Some(InputInstruction::MoveLeft(s)), "S"|"s"=>Some(InputInstruction::MoveBack(s)), "D"|"d"=>Some(InputInstruction::MoveRight(s)), "E"|"e"=>Some(InputInstruction::MoveUp(s)), "Q"|"q"=>Some(InputInstruction::MoveDown(s)), "Z"|"z"=>Some(InputInstruction::Zoom(s)), "R"|"r"=>if s{ //mouse needs to be reset since the position is absolute self.mouse=strafesnet_common::mouse::MouseState::default(); Some(InputInstruction::ResetAndRestart) }else{None}, "F"|"f"=>if s{Some(InputInstruction::PracticeFly)}else{None}, _=>None, }, _=>None, } ```
aidan9382 force-pushed master from b0aecc3fd1 to fcacf7026f 2024-10-18 19:26:59 +00:00 Compare
Author
Member

I've gone ahead and implemented your suggestion if the allocation is an issue
I also tried moving it off master in my fork, but the PR doesn't allow changing which branch I'm pulling from for some reason, only which one im pushing to, so for now it's gonna have to stay on master

I've gone ahead and implemented your suggestion if the allocation is an issue I also tried moving it off master in my fork, but the PR doesn't allow changing which branch I'm pulling *from* for some reason, only which one im pushing *to*, so for now it's gonna have to stay on master
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u master:aidan9382-master
git checkout aidan9382-master
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: StrafesNET/strafe-client#7
No description provided.