Skip to content

Instantly share code, notes, and snippets.

View philldev's full-sized avatar
🏠
Working from home

D Wolley philldev

🏠
Working from home
  • Weekendinc
  • Manado, Indonesia
  • 22:54 (UTC -12:00)
  • X @deddywolley
View GitHub Profile
<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',
@philldev
philldev / collision.ts
Created December 25, 2022 05:36
check collision between 2 rectangle
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
)
}
@philldev
philldev / keyboard-input.ts
Last active December 25, 2022 04:49
Keyboard Input Typescript
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'
}
}