Re-added keyboard controls alongside joysticks

This commit is contained in:
2025-11-11 13:47:58 -05:00
parent fb8cf9bbfc
commit c225ee696a

View File

@ -45,6 +45,7 @@ class Joystick {
deactivate() {
this.active = false;
this.reset();
}
touchInRange(x, y) {
@ -1018,13 +1019,20 @@ function animate() {
if (isManualInputMode) {
const maxSpeed = parseFloat(keyboardMaxSpeed.value);
const maxRotation = parseFloat(keyboardMaxRotation.value);
// xSpeed = manualInputVelX;
// ySpeed = -manualInputVelY; // Negative because canvas Y axis is inverted
// turnSpeed = manualInputOmega;
xSpeed = leftJoystick.getX() * maxSpeed;
ySpeed = -leftJoystick.getY() * maxSpeed;
turnSpeed = rightJoystick.getX() * maxRotation;
// Combine keyboard and joystick inputs
const keyboardX = manualInputVelX;
const keyboardY = -manualInputVelY; // Negative because canvas Y axis is inverted
const keyboardOmega = manualInputOmega;
const joystickX = leftJoystick.getX() * maxSpeed;
const joystickY = -leftJoystick.getY() * maxSpeed;
const joystickOmega = rightJoystick.getX() * maxRotation;
// Use joystick if active, otherwise use keyboard
xSpeed = leftJoystick.active ? joystickX : keyboardX;
ySpeed = leftJoystick.active ? joystickY : keyboardY;
turnSpeed = rightJoystick.active ? joystickOmega : keyboardOmega;
} else {
xSpeed = parseFloat(vxSlider.value);
ySpeed = -parseFloat(vySlider.value);