fix: 优化跳跃和下落手感

This commit is contained in:
cancerai committed 2026-10-24 01:54:39 +08:00
1 parent ada64fe4be
commit afe2f64b9b
25 files changed
+1197 -188

No files matched your search

+13 -1
View File
@@ -1,5 +1,5 @@
// 输入:IWBT 经典键位(Shift 跳 / Z 跳 / X 射击 / R 重来)
const BIND = {
export const BIND = {
left: ['ArrowLeft', 'KeyA'],
right: ['ArrowRight', 'KeyD'],
up: ['ArrowUp', 'KeyW'],
@@ -12,6 +12,9 @@ const BIND = {
menu: ['KeyQ'],
};
// 出厂键位快照(供设置里的「恢复默认」使用)
const DEFAULT_BIND = JSON.parse(JSON.stringify(BIND));
const down = new Set(); // 当前按住的原始 code
const now = {}; // action 是否按下
const prev = {}; // 上一帧
@@ -75,6 +78,15 @@ addEventListener('keyup', e => {
});
addEventListener('blur', () => { down.clear(); refresh(); });
// ---------------- 键位自定义(设置界面调用) ----------------
/** 返回一份出厂键位的深拷贝 */
export function defaultBindings() { return JSON.parse(JSON.stringify(DEFAULT_BIND)); }
/** 用一份 {action: [code,...]} 映射覆盖当前生效键位(设置确定后调用) */
export function applyBindings(map) {
if (!map) return;
for (const act in map) if (act in BIND) BIND[act] = map[act].slice();
}
// 初始化
for (const act in BIND) { now[act] = false; prev[act] = false; }
export const ACTIONS = Object.keys(BIND);