Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 8x 13x 13x 31x 13x 13x 8x 4x 4x 8x 8x 8x 8x 8x | import type { Tile } from '@/components/GameCanvas/GameCanvas.types'; import type { Ref } from 'vue'; export function useTileEngine(tiles: Ref<Tile[]>, tileSize: Ref<number>) { function getTileAt(x: number, y: number): Tile | null { return ( tiles.value.find((tile) => { return x >= tile.x && x <= tile.x + tileSize.value && y >= tile.y && y <= tile.y + tileSize.value && !tile.flipped && !tile.matched; }) ?? null ); } function isMatchByName(tileA: Tile, tileB: Tile): boolean { return tileA.name === tileB.name; } return { getTileAt, isMatchByName, }; } |