This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script lang="ts"> | |
| import type { Action } from 'svelte/action'; | |
| let colors = [ | |
| 'bg-red-solid', | |
| 'bg-yellow-solid', | |
| 'bg-green-solid', | |
| 'bg-blue-solid', | |
| 'bg-indigo-solid', | |
| 'bg-purple-solid', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const collided = (r1: Rectangle, r2: Rectangle) => { | |
| return ( | |
| r1.position.x + r1.size.width >= r2.position.x && | |
| r1.position.y + r1.size.height >= r2.position.y && | |
| r1.position.y <= r2.position.y + r2.size.height && | |
| r1.position.x <= r2.position.x + r2.size.height | |
| ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type KeyboardState = 'pressed' | 'down' | 'released' | 'up' | |
| class Keyboard { | |
| private _keys: Record<string, KeyboardState> = {} | |
| constructor(keys: string[]) { | |
| for (const _key of keys) { | |
| this._keys[_key] = 'up' | |
| } | |
| } |