Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified digital steering for smoother control #435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

complyue
Copy link
Contributor

This PR make use of parabolic curve to smooth the steering control. I.e. short-press of steering btns would commit weaker control, long-press of the btns would commit stronger control. Keyboard & touch input handlers are updated uniformly.

Please review.

@complyue
Copy link
Contributor Author

Unfortunately rm of core/src/com/agateau/pixelwheels/gameinput/TouchInputUtils.java is wrongly identified by git as modified and renamed to core/src/com/agateau/pixelwheels/gameinput/DigitalSteering.java. Hope that don't bother too much for review.

See:

complyue@0f29d66

complyue@48bdee7

Copy link
Owner

@agateau agateau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea overall, just some minor remarks. Thanks!

Comment on lines 30 to 32
// full steer in original direction,
// assuming player intended to reverse at that direction
rawDirection = Math.signum(rawDirection);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part. I think direction should be unchanged if both left & right are pressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added more reasoning as more elaborated comments there, please review and advise further.

return MathUtils.clamp(direction, -1, 1);
public class DigitalSteering {

private float rawDirection = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: private member variables must have a m prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@@ -61,11 +62,10 @@ public Array<GameInputHandler> getAllHandlers() {
public GameInput getGameInput() {
mInput.braking = isBraking();
mInput.accelerating = !mInput.braking;
if (!mInput.braking) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to keep the if (!mInput.braking) { here: in this input mode, pressing both directions is used to drive backward.

Copy link
Contributor Author

@complyue complyue Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this meant to propagate the player action to DigitalSteering so the trickery logic can be done there. I've elaborated the description by added comments there. I admit straight braking/reversing is sacrificed in favor of fast-reverse-at-a-direction by doing the logic there. Please review the updated comments there and give further advice.

direction = 0;
}
return MathUtils.clamp(direction, -1, 1);
public class DigitalSteering {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This comment is for line 2 but GitHub won't let me comment on it)

You should change the copyright year and owner of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@complyue complyue requested a review from agateau May 6, 2024 08:56
Copy link
Owner

@agateau agateau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for dropping the ball here. I messed up and forgot to review your work. I finally did so yesterday.

Unifying steering is a really good idea. It made me realize the code in master have different behaviors for keyboard and touch inputs: when the player no longer press a direction button, keyboard handling would progressively return direction to 0, while touch handling would return it immediately.

I am not, however, convinced by the new left+right behavior: after test playing it on my phone, I found it frustrating because it is hard to predict in which direction the vehicle is going to reverse. This is especially annoying when it causes the vehicle to reverse on a turbo tile, which prevents going further. Can you revert that change?

Sorry again for the huge answering delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants