mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-23 11:04:10 +02:00
fix wasdVec calculation
This commit is contained in:
@@ -142,7 +142,20 @@ const antialias = prefer.model('world.antialias');
|
|||||||
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
||||||
//const useVirtualJoystick = true;
|
//const useVirtualJoystick = true;
|
||||||
|
|
||||||
const wasdVec = { x: 0, y: 0 };
|
let isWPressing = false;
|
||||||
|
let isSPressing = false;
|
||||||
|
let isAPressing = false;
|
||||||
|
let isDPressing = false;
|
||||||
|
|
||||||
|
function calcWasdVec() {
|
||||||
|
const vec = { x: 0, y: 0 };
|
||||||
|
if (isWPressing) vec.y -= 1;
|
||||||
|
if (isSPressing) vec.y += 1;
|
||||||
|
if (isAPressing) vec.x -= 1;
|
||||||
|
if (isDPressing) vec.x += 1;
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
let isDashing = false;
|
let isDashing = false;
|
||||||
|
|
||||||
const joyStickRadiusPx = 100;
|
const joyStickRadiusPx = 100;
|
||||||
@@ -312,25 +325,25 @@ onMounted(async () => {
|
|||||||
|
|
||||||
switch (ev.code) {
|
switch (ev.code) {
|
||||||
case 'KeyW':
|
case 'KeyW':
|
||||||
wasdVec.y = -1;
|
isWPressing = true;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyS':
|
case 'KeyS':
|
||||||
wasdVec.y = 1;
|
isSPressing = true;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyA':
|
case 'KeyA':
|
||||||
wasdVec.x = -1;
|
isAPressing = true;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyD':
|
case 'KeyD':
|
||||||
wasdVec.x = 1;
|
isDPressing = true;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'ShiftLeft':
|
case 'ShiftLeft':
|
||||||
case 'ShiftRight':
|
case 'ShiftRight':
|
||||||
isDashing = true;
|
isDashing = true;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -338,25 +351,25 @@ onMounted(async () => {
|
|||||||
canvas.value!.addEventListener('keyup', (ev) => {
|
canvas.value!.addEventListener('keyup', (ev) => {
|
||||||
switch (ev.code) {
|
switch (ev.code) {
|
||||||
case 'KeyW':
|
case 'KeyW':
|
||||||
wasdVec.y = 0;
|
isWPressing = false;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyS':
|
case 'KeyS':
|
||||||
wasdVec.y = 0;
|
isSPressing = false;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyA':
|
case 'KeyA':
|
||||||
wasdVec.x = 0;
|
isAPressing = false;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'KeyD':
|
case 'KeyD':
|
||||||
wasdVec.x = 0;
|
isDPressing = false;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
case 'ShiftLeft':
|
case 'ShiftLeft':
|
||||||
case 'ShiftRight':
|
case 'ShiftRight':
|
||||||
isDashing = false;
|
isDashing = false;
|
||||||
controller.setCameraMoveVector(wasdVec, isDashing);
|
controller.setCameraMoveVector(calcWasdVec(), isDashing);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user