fix: 修复了冰块惯性问题和死亡效果

This commit is contained in:
cancerai committed 2026-10-22 19:43:01 +08:00
1 parent 47a462be01
commit 4b3dfd635b
15 files changed
+633 -38

No files matched your search

+15
View File
@@ -15,6 +15,7 @@ const BIND = {
const down = new Set(); // 当前按住的原始 code
const now = {}; // action 是否按下
const prev = {}; // 上一帧
const touch = {}; // action -> bool(来自触屏虚拟按键)
const blocked = new Set(['Space', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Tab']);
export const Input = {
@@ -44,10 +45,24 @@ function refresh() {
for (const act in BIND) {
let v = false;
for (const c of BIND[act]) if (down.has(c)) { v = true; break; }
if (touch[act]) v = true; // 触屏虚拟按键
now[act] = Input.enabled ? v : false;
}
}
// ---------------- 触屏虚拟按键接口 ----------------
export function setTouch(action, on) {
if (!(action in touch)) touch[action] = false;
if (touch[action] === on) return;
touch[action] = on;
refresh();
}
export function clearTouch() {
let any = false;
for (const k in touch) if (touch[k]) { touch[k] = false; any = true; }
if (any) refresh();
}
addEventListener('keydown', e => {
if (blocked.has(e.code)) e.preventDefault();
if (e.repeat) return;