From 29a8755784bdcf45e36ac0d784a97c94cbd9c119 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Sun, 5 Nov 2023 11:14:34 +0000 Subject: add move limit of 1 per sec --- frontend/src/views/JoinView.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/views/JoinView.vue b/frontend/src/views/JoinView.vue index 83e00c2..83421ee 100644 --- a/frontend/src/views/JoinView.vue +++ b/frontend/src/views/JoinView.vue @@ -8,6 +8,7 @@ const sessionId = route.params.id; const joiningGame = ref(true); const connected = ref(false); const gameState = ref(''); +const controlsLocked = ref(false); const socket = new WebSocket(`${import.meta.env.VITE_BACKEND_WS_URL}`); socket.onopen = () => { @@ -26,6 +27,13 @@ socket.onmessage = (event) => { }; function sendMove(move: string) { + if (controlsLocked.value) { + return; + } + controlsLocked.value = true; + setTimeout(() => { + controlsLocked.value = false; + }, 1000); socket.send(JSON.stringify({ action: 'move', sessionId: sessionId, @@ -56,9 +64,9 @@ function sendRight() {

Connected to "{{ sessionId }}"

Waiting for host to start the game...

- - - + + +
-- cgit v1.2.3-70-g09d2