Skip to content

Commit

Permalink
fix counter logic
Browse files Browse the repository at this point in the history
  • Loading branch information
da-in committed Mar 17, 2024
1 parent b807573 commit 198d70f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hooks/use-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const usePlayer = (element: Ref<HTMLCanvasElement | undefined>) => {

const scoreRef = ref(0)
const collisions = ref<Set<number>>(new Set())
const hasLineCollisions = computed(() => collisions.value.size > 0)

const widthRef = ref(0)
const heightRef = ref(0)
Expand Down Expand Up @@ -119,13 +120,12 @@ export const usePlayer = (element: Ref<HTMLCanvasElement | undefined>) => {
endGame()
})

watch(collisions.value, (value) => {
if (value.size > 0) {
watch(hasLineCollisions, (value) => {
if (value) {
start()
return
}
if (value.size === 0) {
reset()
}
reset()
})

const addBlock = () => {
Expand Down

0 comments on commit 198d70f

Please sign in to comment.