Clamp the speed to 1 so using dpad will not double the speed

This commit is contained in:
dogtopus
2022-10-12 19:17:27 -03:00
parent c70da21df6
commit c07c4200f7

View File

@@ -64,6 +64,7 @@ public final class MovementHandler implements PressAction {
// Do a implicit square here
movementR = this.slowdownFactor * (Math.pow(this.movementSideways, 2) + Math.pow(this.movementForward, 2));
movementR = MathHelper.clamp(movementR, 0.f, 1.f);
movementTheta = Math.atan2(this.movementForward, this.movementSideways);
player.input.movementForward = (float) (movementR * Math.sin(movementTheta));
player.input.movementSideways = (float) (movementR * Math.cos(movementTheta));