diff --git a/src/Game.vue b/src/Game.vue index 8dc3f80..7d0ab7b 100644 --- a/src/Game.vue +++ b/src/Game.vue @@ -21,6 +21,7 @@ const board = $ref( let message = $ref('') let allowInput = true let currentRowIndex = $ref(0) +let shakeRowIndex = $ref(-1) const currentRow = $computed(() => board[currentRowIndex]) // keep track of revealed letter state for the keyboard @@ -68,6 +69,7 @@ function completeRow() { if (currentRow.every((tile) => tile.letter)) { const word = currentRow.map((tile) => tile.letter).join('') if (!allWords.includes(word) && word !== answer) { + shake() showMessage(`Not in word list`) return } @@ -106,6 +108,7 @@ function completeRow() { showMessage(answer.toUpperCase()) } } else { + shake() showMessage('Not enough letters') } } @@ -116,6 +119,13 @@ function showMessage(msg: string) { message = '' }, 1000) } + +function shake() { + shakeRowIndex = currentRowIndex + setTimeout(() => { + shakeRowIndex = -1 + }, 1000) +}