diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-18 11:21:23 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:20:50 +0200 |
commit | 3e8c24375f064487365a66c20fba20bea8e1f860 (patch) | |
tree | 590f03a6fed22ae3abfba3ae1aecb5a1d18a2b13 /test-client/main.ts | |
parent | 20a978e4f91e03588bf89d2426ee215f176b1ac7 (diff) | |
download | hurrycurry-3e8c24375f064487365a66c20fba20bea8e1f860.tar hurrycurry-3e8c24375f064487365a66c20fba20bea8e1f860.tar.bz2 hurrycurry-3e8c24375f064487365a66c20fba20bea8e1f860.tar.zst |
active recipes work
Diffstat (limited to 'test-client/main.ts')
-rw-r--r-- | test-client/main.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index ef84689f..1b034f28 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -49,7 +49,7 @@ let scale = 0 function send(p: PacketS) { ws.send(JSON.stringify(p)) } function packet(p: PacketC) { - if (!("position" in p)) console.log(p); + if (!("position" in p) && !("set_active" in p)) console.log(p); if ("joined" in p) { my_id = p.joined.id data = p.joined.data @@ -90,9 +90,12 @@ const keys_down = new Set(); const HANDLED_KEYS = ["KeyW", "KeyA", "KeyS", "KeyD", "Space"] function keyboard(ev: KeyboardEvent, down: boolean) { if (HANDLED_KEYS.includes(ev.code)) ev.preventDefault() - if (ev.code == "Space") interact(down) + let change; + if (down) change = !keys_down.has(ev.code) + else change = keys_down.has(ev.code) if (down) keys_down.add(ev.code) else keys_down.delete(ev.code) + if (change && ev.code == "Space") interact(down) } function get_interact_target(): V2 | undefined { |