Mid-Simulator/dist/game.js.map
2022-04-24 09:47:31 +00:00

7 lines
299 KiB
Text

{
"version": 3,
"sources": ["../node_modules/kaboom/src/utils.ts", "../node_modules/kaboom/src/math.ts", "../node_modules/kaboom/src/fps.ts", "../node_modules/kaboom/src/timer.ts", "../node_modules/kaboom/src/kaboom.ts", "../code/easing.js", "../code/main.js"],
"sourcesContent": ["export class IDList<T> extends Map<number, T> {\n\t_lastID: number;\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis._lastID = 0;\n\t}\n\tpush(v: T): number {\n\t\tconst id = this._lastID;\n\t\tthis.set(id, v);\n\t\tthis._lastID++;\n\t\treturn id;\n\t}\n\tpushd(v: T): () => void {\n\t\tconst id = this.push(v);\n\t\treturn () => this.delete(id);\n\t}\n}\n\nexport function deepEq(o1: any, o2: any): boolean {\n\tconst t1 = typeof o1;\n\tconst t2 = typeof o2;\n\tif (t1 !== t2) {\n\t\treturn false;\n\t}\n\tif (t1 === \"object\" && t2 === \"object\") {\n\t\tconst k1 = Object.keys(o1);\n\t\tconst k2 = Object.keys(o2);\n\t\tif (k1.length !== k2.length) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (const k of k1) {\n\t\t\tconst v1 = o1[k];\n\t\t\tconst v2 = o2[k];\n\t\t\tif (!(typeof v1 === \"function\" && typeof v2 === \"function\")) {\n\t\t\t\tif (!deepEq(v1, v2)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\treturn o1 === o2;\n}\n\nexport function downloadURL(url: string, filename: string) {\n\tconst a = document.createElement(\"a\");\n\tdocument.body.appendChild(a);\n\ta.setAttribute(\"style\", \"display: none\");\n\ta.href = url;\n\ta.download = filename;\n\ta.click();\n\tdocument.body.removeChild(a);\n}\n\nexport function downloadBlob(blob: Blob, filename: string) {\n\tconst url = URL.createObjectURL(blob);\n\tdownloadURL(url, filename);\n\tURL.revokeObjectURL(url);\n}\n\nexport function isDataURL(str: string) {\n\treturn str.match(/^data:\\w+\\/\\w+;base64,.+/);\n}\n\nexport const uid = (() => {\n\tlet id = 0;\n\treturn () => id++;\n})();\n\nconst warned = new Set();\n\nexport function deprecateMsg(oldName: string, newName: string) {\n\tif (!warned.has(oldName)) {\n\t\twarned.add(oldName);\n\t\tconsole.warn(`${oldName} is deprecated. Use ${newName} instead.`);\n\t}\n}\n\nexport const deprecate = (oldName: string, newName: string, newFunc: (...args) => any) => (...args) => {\n\tdeprecateMsg(oldName, newName);\n\treturn newFunc(...args);\n};\n", "import {\n\tVec4,\n\tPoint,\n\tPolygon,\n\tArea,\n} from \"./types\";\n\nimport {\n\tdeprecateMsg,\n} from \"./utils\";\n\nexport function deg2rad(deg: number): number {\n\treturn deg * Math.PI / 180;\n}\n\nexport function rad2deg(rad: number): number {\n\treturn rad * 180 / Math.PI;\n}\n\nexport function clamp(\n\tval: number,\n\tmin: number,\n\tmax: number,\n): number {\n\tif (min > max) {\n\t\treturn clamp(val, max, min);\n\t}\n\treturn Math.min(Math.max(val, min), max);\n}\n\nexport function lerp(\n\ta: number,\n\tb: number,\n\tt: number,\n): number {\n\treturn a + (b - a) * t;\n}\n\nexport function map(\n\tv: number,\n\tl1: number,\n\th1: number,\n\tl2: number,\n\th2: number,\n): number {\n\treturn l2 + (v - l1) / (h1 - l1) * (h2 - l2);\n}\n\nexport function mapc(\n\tv: number,\n\tl1: number,\n\th1: number,\n\tl2: number,\n\th2: number,\n): number {\n\treturn clamp(map(v, l1, h1, l2, h2), l2, h2);\n}\n\nexport class Vec2 {\n\tx: number = 0;\n\ty: number = 0;\n\tconstructor(x: number = 0, y: number = x) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t}\n\tstatic fromAngle(deg: number) {\n\t\tconst angle = deg2rad(deg);\n\t\treturn new Vec2(Math.cos(angle), Math.sin(angle));\n\t}\n\tstatic LEFT = new Vec2(-1, 0);\n\tstatic RIGHT = new Vec2(1, 0);\n\tstatic UP = new Vec2(0, -1);\n\tstatic DOWN = new Vec2(0, 1);\n\tclone(): Vec2 {\n\t\treturn new Vec2(this.x, this.y);\n\t}\n\tadd(...args): Vec2 {\n\t\tconst p2 = vec2(...args);\n\t\treturn new Vec2(this.x + p2.x, this.y + p2.y);\n\t}\n\tsub(...args): Vec2 {\n\t\tconst p2 = vec2(...args);\n\t\treturn new Vec2(this.x - p2.x, this.y - p2.y);\n\t}\n\tscale(...args): Vec2 {\n\t\tconst s = vec2(...args);\n\t\treturn new Vec2(this.x * s.x, this.y * s.y);\n\t}\n\tdist(...args): number {\n\t\tconst p2 = vec2(...args);\n\t\treturn Math.sqrt(\n\t\t\t(this.x - p2.x) * (this.x - p2.x)\n\t\t\t+ (this.y - p2.y) * (this.y - p2.y)\n\t\t);\n\t}\n\tlen(): number {\n\t\treturn this.dist(new Vec2(0, 0));\n\t}\n\tunit(): Vec2 {\n\t\treturn this.scale(1 / this.len());\n\t}\n\tnormal(): Vec2 {\n\t\treturn new Vec2(this.y, -this.x);\n\t}\n\tdot(p2: Vec2): number {\n\t\treturn this.x * p2.x + this.y * p2.y;\n\t}\n\tangle(...args): number {\n\t\tconst p2 = vec2(...args);\n\t\treturn rad2deg(Math.atan2(this.y - p2.y, this.x - p2.x));\n\t}\n\tlerp(p2: Vec2, t: number): Vec2 {\n\t\treturn new Vec2(lerp(this.x, p2.x, t), lerp(this.y, p2.y, t));\n\t}\n\ttoFixed(n: number): Vec2 {\n\t\treturn new Vec2(Number(this.x.toFixed(n)), Number(this.y.toFixed(n)));\n\t}\n\teq(other: Vec2): boolean {\n\t\treturn this.x === other.x && this.y === other.y;\n\t}\n\ttoString(): string {\n\t\treturn `(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`;\n\t}\n\tstr(): string {\n\t\treturn this.toString();\n\t}\n}\n\nexport function vec2(...args): Vec2 {\n\tif (args.length === 1) {\n\t\tif (args[0] instanceof Vec2) {\n\t\t\treturn vec2(args[0].x, args[0].y);\n\t\t} else if (Array.isArray(args[0]) && args[0].length === 2) {\n\t\t\treturn vec2.apply(null, args[0]);\n\t\t}\n\t}\n\treturn new Vec2(...args);\n}\n\nexport class Vec3 {\n\tx: number = 0;\n\ty: number = 0;\n\tz: number = 0;\n\tconstructor(x: number, y: number, z: number) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t}\n\txy() {\n\t\treturn vec2(this.x, this.y);\n\t}\n}\n\nexport const vec3 = (x, y, z) => new Vec3(x, y, z);\n\nexport class Color {\n\n\tr: number = 255;\n\tg: number = 255;\n\tb: number = 255;\n\n\tconstructor(r: number, g: number, b: number) {\n\t\tthis.r = clamp(r, 0, 255);\n\t\tthis.g = clamp(g, 0, 255);\n\t\tthis.b = clamp(b, 0, 255);\n\t}\n\n\tstatic fromArray(arr: number[]) {\n\t\treturn new Color(arr[0], arr[1], arr[2])\n\t}\n\n\tstatic RED = rgb(255, 0, 0);\n\tstatic GREEN = rgb(0, 255, 0);\n\tstatic BLUE = rgb(0, 0, 255);\n\tstatic YELLOW = rgb(255, 255, 0);\n\tstatic MAGENTA = rgb(255, 0, 255);\n\tstatic CYAN = rgb(0, 255, 255);\n\tstatic WHITE = rgb(255, 255, 255);\n\tstatic BLACK = rgb(0, 0, 0);\n\n\tclone(): Color {\n\t\treturn new Color(this.r, this.g, this.b);\n\t}\n\n\tlighten(a: number): Color {\n\t\treturn new Color(this.r + a, this.g + a, this.b + a);\n\t}\n\n\tdarken(a: number): Color {\n\t\treturn this.lighten(-a);\n\t}\n\n\tinvert(): Color {\n\t\treturn new Color(255 - this.r, 255 - this.g, 255 - this.b);\n\t}\n\n\tmult(other: Color): Color {\n\t\treturn new Color(\n\t\t\tthis.r * other.r / 255,\n\t\t\tthis.g * other.g / 255,\n\t\t\tthis.b * other.b / 255,\n\t\t);\n\t}\n\n\teq(other: Color): boolean {\n\t\treturn this.r === other.r\n\t\t\t&& this.g === other.g\n\t\t\t&& this.b === other.b\n\t\t\t;\n\t}\n\n\tstr(): string {\n\t\tdeprecateMsg(\"str()\", \"toString()\");\n\t\treturn `(${this.r}, ${this.g}, ${this.b})`;\n\t}\n\n\ttoString(): string {\n\t\treturn `(${this.r}, ${this.g}, ${this.b})`;\n\t}\n\n\tstatic fromHSL(h: number, s: number, l: number) {\n\n\t\tif (s == 0){\n\t\t\treturn rgb(255 * l, 255 * l, 255 * l);\n\t\t}\n\n\t\tconst hue2rgb = (p, q, t) => {\n\t\t\tif (t < 0) t += 1;\n\t\t\tif (t > 1) t -= 1;\n\t\t\tif (t < 1 / 6) return p + (q - p) * 6 * t;\n\t\t\tif (t < 1 / 2) return q;\n\t\t\tif (t < 2 / 3) return p + (q - p) * (2/3 - t) * 6;\n\t\t\treturn p;\n\t\t}\n\n\t\tconst q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n\t\tconst p = 2 * l - q;\n\t\tconst r = hue2rgb(p, q, h + 1 / 3);\n\t\tconst g = hue2rgb(p, q, h);\n\t\tconst b = hue2rgb(p, q, h - 1 / 3);\n\n\t\treturn new Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255));\n\n\t}\n\n}\n\nexport function rgb(...args): Color {\n\tif (args.length === 0) {\n\t\treturn new Color(255, 255, 255);\n\t} else if (args.length === 1) {\n\t\tif (args[0] instanceof Color) {\n\t\t\treturn args[0].clone();\n\t\t} else if (Array.isArray(args[0]) && args[0].length === 3) {\n\t\t\treturn Color.fromArray(args[0]);\n\t\t}\n\t}\n\t// @ts-ignore\n\treturn new Color(...args);\n}\n\nexport const hsl2rgb = (h, s, l) => Color.fromHSL(h, s, l);\n\nexport class Quad {\n\tx: number = 0;\n\ty: number = 0;\n\tw: number = 1;\n\th: number = 1;\n\tconstructor(x: number, y: number, w: number, h: number) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.w = w;\n\t\tthis.h = h;\n\t}\n\tscale(other: Quad): Quad {\n\t\treturn new Quad(\n\t\t\tthis.x + this.w * other.x,\n\t\t\tthis.y + this.h * other.y,\n\t\t\tthis.w * other.w,\n\t\t\tthis.h * other.h\n\t\t);\n\t}\n\tclone(): Quad {\n\t\treturn new Quad(this.x, this.y, this.w, this.h);\n\t}\n\teq(other: Quad): boolean {\n\t\treturn this.x === other.x\n\t\t\t&& this.y === other.y\n\t\t\t&& this.w === other.w\n\t\t\t&& this.h === other.h;\n\t}\n\ttoString(): string {\n\t\treturn `quad(${this.x}, ${this.y}, ${this.w}, ${this.h})`;\n\t}\n}\n\nexport function quad(x: number, y: number, w: number, h: number): Quad {\n\treturn new Quad(x, y, w, h);\n}\n\nexport class Mat4 {\n\n\tm: number[] = [\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1,\n\t];\n\n\tconstructor(m?: number[]) {\n\t\tif (m) {\n\t\t\tthis.m = m;\n\t\t}\n\t}\n\n\tclone(): Mat4 {\n\t\treturn new Mat4(this.m);\n\t};\n\n\tmult(other: Mat4): Mat4 {\n\n\t\tconst out = [];\n\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tfor (let j = 0; j < 4; j++) {\n\t\t\t\tout[i * 4 + j] =\n\t\t\t\t\tthis.m[0 * 4 + j] * other.m[i * 4 + 0] +\n\t\t\t\t\tthis.m[1 * 4 + j] * other.m[i * 4 + 1] +\n\t\t\t\t\tthis.m[2 * 4 + j] * other.m[i * 4 + 2] +\n\t\t\t\t\tthis.m[3 * 4 + j] * other.m[i * 4 + 3];\n\t\t\t}\n\t\t}\n\n\t\treturn new Mat4(out);\n\n\t}\n\n\tmultVec4(p: Vec4): Vec4 {\n\t\treturn {\n\t\t\tx: p.x * this.m[0] + p.y * this.m[4] + p.z * this.m[8] + p.w * this.m[12],\n\t\t\ty: p.x * this.m[1] + p.y * this.m[5] + p.z * this.m[9] + p.w * this.m[13],\n\t\t\tz: p.x * this.m[2] + p.y * this.m[6] + p.z * this.m[10] + p.w * this.m[14],\n\t\t\tw: p.x * this.m[3] + p.y * this.m[7] + p.z * this.m[11] + p.w * this.m[15]\n\t\t};\n\t}\n\n\tmultVec3(p: Vec3): Vec3 {\n\t\tconst p4 = this.multVec4({\n\t\t\tx: p.x,\n\t\t\ty: p.y,\n\t\t\tz: p.z,\n\t\t\tw: 1.0,\n\t\t});\n\t\treturn vec3(p4.x, p4.y, p4.z);\n\t}\n\n\tmultVec2(p: Vec2): Vec2 {\n\t\treturn vec2(\n\t\t\tp.x * this.m[0] + p.y * this.m[4] + 0 * this.m[8] + 1 * this.m[12],\n\t\t\tp.x * this.m[1] + p.y * this.m[5] + 0 * this.m[9] + 1 * this.m[13],\n\t\t);\n\t}\n\n\tstatic translate(p: Vec2): Mat4 {\n\t\treturn new Mat4([\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\tp.x, p.y, 0, 1,\n\t\t]);\n\t}\n\n\tstatic scale(s: Vec2): Mat4 {\n\t\treturn new Mat4([\n\t\t\ts.x, 0, 0, 0,\n\t\t\t0, s.y, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1,\n\t\t]);\n\t}\n\n\tstatic rotateX(a: number): Mat4 {\n\t\ta = deg2rad(-a);\n\t\treturn new Mat4([\n\t\t\t1, 0, 0, 0,\n\t\t\t0, Math.cos(a), -Math.sin(a), 0,\n\t\t\t0, Math.sin(a), Math.cos(a), 0,\n\t\t\t0, 0, 0, 1,\n\t\t]);\n\t}\n\n\tstatic rotateY(a: number): Mat4 {\n\t\ta = deg2rad(-a);\n\t\treturn new Mat4([\n\t\t\tMath.cos(a), 0, Math.sin(a), 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t-Math.sin(a), 0, Math.cos(a), 0,\n\t\t\t0, 0, 0, 1,\n\t\t]);\n\t}\n\n\tstatic rotateZ(a: number): Mat4 {\n\t\ta = deg2rad(-a);\n\t\treturn new Mat4([\n\t\t\tMath.cos(a), -Math.sin(a), 0, 0,\n\t\t\tMath.sin(a), Math.cos(a), 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1,\n\t\t]);\n\t}\n\n\ttranslate(p: Vec2): Mat4 {\n\t\treturn this.mult(Mat4.translate(p));\n\t}\n\n\tscale(s: Vec2): Mat4 {\n\t\treturn this.mult(Mat4.scale(s));\n\t}\n\n\trotateX(a: number): Mat4 {\n\t\treturn this.mult(Mat4.rotateX(a));\n\t}\n\n\trotateY(a: number): Mat4 {\n\t\treturn this.mult(Mat4.rotateY(a));\n\t}\n\n\trotateZ(a: number): Mat4 {\n\t\treturn this.mult(Mat4.rotateZ(a));\n\t}\n\n\tinvert(): Mat4 {\n\n\t\tconst out = [];\n\n\t\tconst f00 = this.m[10] * this.m[15] - this.m[14] * this.m[11];\n\t\tconst f01 = this.m[9] * this.m[15] - this.m[13] * this.m[11];\n\t\tconst f02 = this.m[9] * this.m[14] - this.m[13] * this.m[10];\n\t\tconst f03 = this.m[8] * this.m[15] - this.m[12] * this.m[11];\n\t\tconst f04 = this.m[8] * this.m[14] - this.m[12] * this.m[10];\n\t\tconst f05 = this.m[8] * this.m[13] - this.m[12] * this.m[9];\n\t\tconst f06 = this.m[6] * this.m[15] - this.m[14] * this.m[7];\n\t\tconst f07 = this.m[5] * this.m[15] - this.m[13] * this.m[7];\n\t\tconst f08 = this.m[5] * this.m[14] - this.m[13] * this.m[6];\n\t\tconst f09 = this.m[4] * this.m[15] - this.m[12] * this.m[7];\n\t\tconst f10 = this.m[4] * this.m[14] - this.m[12] * this.m[6];\n\t\tconst f11 = this.m[5] * this.m[15] - this.m[13] * this.m[7];\n\t\tconst f12 = this.m[4] * this.m[13] - this.m[12] * this.m[5];\n\t\tconst f13 = this.m[6] * this.m[11] - this.m[10] * this.m[7];\n\t\tconst f14 = this.m[5] * this.m[11] - this.m[9] * this.m[7];\n\t\tconst f15 = this.m[5] * this.m[10] - this.m[9] * this.m[6];\n\t\tconst f16 = this.m[4] * this.m[11] - this.m[8] * this.m[7];\n\t\tconst f17 = this.m[4] * this.m[10] - this.m[8] * this.m[6];\n\t\tconst f18 = this.m[4] * this.m[9] - this.m[8] * this.m[5];\n\n\t\tout[0] = this.m[5] * f00 - this.m[6] * f01 + this.m[7] * f02;\n\t\tout[4] = -(this.m[4] * f00 - this.m[6] * f03 + this.m[7] * f04);\n\t\tout[8] = this.m[4] * f01 - this.m[5] * f03 + this.m[7] * f05;\n\t\tout[12] = -(this.m[4] * f02 - this.m[5] * f04 + this.m[6] * f05);\n\n\t\tout[1] = -(this.m[1] * f00 - this.m[2] * f01 + this.m[3] * f02);\n\t\tout[5] = this.m[0] * f00 - this.m[2] * f03 + this.m[3] * f04;\n\t\tout[9] = -(this.m[0] * f01 - this.m[1] * f03 + this.m[3] * f05);\n\t\tout[13] = this.m[0] * f02 - this.m[1] * f04 + this.m[2] * f05;\n\n\t\tout[2] = this.m[1] * f06 - this.m[2] * f07 + this.m[3] * f08;\n\t\tout[6] = -(this.m[0] * f06 - this.m[2] * f09 + this.m[3] * f10);\n\t\tout[10] = this.m[0] * f11 - this.m[1] * f09 + this.m[3] * f12;\n\t\tout[14] = -(this.m[0] * f08 - this.m[1] * f10 + this.m[2] * f12);\n\n\t\tout[3] = -(this.m[1] * f13 - this.m[2] * f14 + this.m[3] * f15);\n\t\tout[7] = this.m[0] * f13 - this.m[2] * f16 + this.m[3] * f17;\n\t\tout[11] = -(this.m[0] * f14 - this.m[1] * f16 + this.m[3] * f18);\n\t\tout[15] = this.m[0] * f15 - this.m[1] * f17 + this.m[2] * f18;\n\n\t\tconst det =\n\t\t\tthis.m[0] * out[0] +\n\t\t\tthis.m[1] * out[4] +\n\t\t\tthis.m[2] * out[8] +\n\t\t\tthis.m[3] * out[12];\n\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tfor (let j = 0; j < 4; j++) {\n\t\t\t\tout[i * 4 + j] *= (1.0 / det);\n\t\t\t}\n\t\t}\n\n\t\treturn new Mat4(out);\n\n\t}\n\n\ttoString(): string {\n\t\treturn this.m.toString();\n\t}\n\n}\n\nexport function wave(lo: number, hi: number, t: number, f = Math.sin): number {\n\treturn lo + (f(t) + 1) / 2 * (hi - lo);\n}\n\n// basic ANSI C LCG\nconst A = 1103515245;\nconst C = 12345;\nconst M = 2147483648;\n\nexport class RNG {\n\tseed: number;\n\tconstructor(seed: number) {\n\t\tthis.seed = seed;\n\t}\n\tgen(...args) {\n\t\tif (args.length === 0) {\n\t\t\tthis.seed = (A * this.seed + C) % M;\n\t\t\treturn this.seed / M;\n\t\t} else if (args.length === 1) {\n\t\t\tif (typeof args[0] === \"number\") {\n\t\t\t\treturn this.gen(0, args[0]);\n\t\t\t} else if (args[0] instanceof Vec2) {\n\t\t\t\treturn this.gen(vec2(0, 0), args[0]);\n\t\t\t} else if (args[0] instanceof Color) {\n\t\t\t\treturn this.gen(rgb(0, 0, 0), args[0]);\n\t\t\t}\n\t\t} else if (args.length === 2) {\n\t\t\tif (typeof args[0] === \"number\" && typeof args[1] === \"number\") {\n\t\t\t\treturn (this.gen() * (args[1] - args[0])) + args[0];\n\t\t\t} else if (args[0] instanceof Vec2 && args[1] instanceof Vec2) {\n\t\t\t\treturn vec2(\n\t\t\t\t\tthis.gen(args[0].x, args[1].x),\n\t\t\t\t\tthis.gen(args[0].y, args[1].y),\n\t\t\t\t);\n\t\t\t} else if (args[0] instanceof Color && args[1] instanceof Color) {\n\t\t\t\treturn rgb(\n\t\t\t\t\tthis.gen(args[0].r, args[1].r),\n\t\t\t\t\tthis.gen(args[0].g, args[1].g),\n\t\t\t\t\tthis.gen(args[0].b, args[1].b),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// TODO: let user pass seed\nconst defRNG = new RNG(Date.now());\n\nexport function rng(seed: number): RNG {\n\tdeprecateMsg(\"rng()\", \"new RNG()\");\n\treturn new RNG(seed);\n}\n\nexport function randSeed(seed?: number): number {\n\tif (seed != null) {\n\t\tdefRNG.seed = seed;\n\t}\n\treturn defRNG.seed;\n}\n\nexport function rand(...args) {\n\t// @ts-ignore\n\treturn defRNG.gen(...args);\n}\n\n// TODO: randi() to return 0 / 1?\nexport function randi(...args) {\n\treturn Math.floor(rand(...args));\n}\n\nexport function chance(p: number): boolean {\n\treturn rand() <= p;\n}\n\nexport function choose<T>(list: T[]): T {\n\treturn list[randi(list.length)];\n}\n\n// TODO: better name\nexport function testRectRect2(r1: Rect, r2: Rect): boolean {\n\treturn r1.p2.x >= r2.p1.x\n\t\t&& r1.p1.x <= r2.p2.x\n\t\t&& r1.p2.y >= r2.p1.y\n\t\t&& r1.p1.y <= r2.p2.y;\n}\n\nexport function testRectRect(r1: Rect, r2: Rect): boolean {\n\treturn r1.p2.x > r2.p1.x\n\t\t&& r1.p1.x < r2.p2.x\n\t\t&& r1.p2.y > r2.p1.y\n\t\t&& r1.p1.y < r2.p2.y;\n}\n\n// TODO: better name\nexport function testLineLineT(l1: Line, l2: Line): number | null {\n\n\tif ((l1.p1.x === l1.p2.x && l1.p1.y === l1.p2.y) || (l2.p1.x === l2.p2.x && l2.p1.y === l2.p2.y)) {\n\t\treturn null;\n\t}\n\n\tconst denom = ((l2.p2.y - l2.p1.y) * (l1.p2.x - l1.p1.x) - (l2.p2.x - l2.p1.x) * (l1.p2.y - l1.p1.y));\n\n\t// parallel\n\tif (denom === 0) {\n\t\treturn null;\n\t}\n\n\tconst ua = ((l2.p2.x - l2.p1.x) * (l1.p1.y - l2.p1.y) - (l2.p2.y - l2.p1.y) * (l1.p1.x - l2.p1.x)) / denom;\n\tconst ub = ((l1.p2.x - l1.p1.x) * (l1.p1.y - l2.p1.y) - (l1.p2.y - l1.p1.y) * (l1.p1.x - l2.p1.x)) / denom;\n\n\t// is the intersection on the segments\n\tif (ua < 0 || ua > 1 || ub < 0 || ub > 1) {\n\t\treturn null;\n\t}\n\n\treturn ua;\n\n}\n\nexport function testLineLine(l1: Line, l2: Line): Vec2 | null {\n\tconst t = testLineLineT(l1, l2);\n\tif (!t) return null;\n\treturn vec2(\n\t\tl1.p1.x + t * (l1.p2.x - l1.p1.x),\n\t\tl1.p1.y + t * (l1.p2.y - l1.p1.y),\n\t);\n}\n\nexport function testRectLine(r: Rect, l: Line): boolean {\n\tif (testRectPoint(r, l.p1) || testRectPoint(r, l.p2)) {\n\t\treturn true;\n\t}\n\treturn !!testLineLine(l, new Line(r.p1, vec2(r.p2.x, r.p1.y)))\n\t\t|| !!testLineLine(l, new Line(vec2(r.p2.x, r.p1.y), r.p2))\n\t\t|| !!testLineLine(l, new Line(r.p2, vec2(r.p1.x, r.p2.y)))\n\t\t|| !!testLineLine(l, new Line(vec2(r.p1.x, r.p2.y), r.p1));\n}\n\nexport function testRectPoint2(r: Rect, pt: Point): boolean {\n\treturn pt.x >= r.p1.x && pt.x <= r.p2.x && pt.y >= r.p1.y && pt.y <= r.p2.y;\n}\n\nexport function testRectPoint(r: Rect, pt: Point): boolean {\n\treturn pt.x > r.p1.x && pt.x < r.p2.x && pt.y > r.p1.y && pt.y < r.p2.y;\n}\n\nexport function testRectCircle(r: Rect, c: Circle): boolean {\n\tconst nx = Math.max(r.p1.x, Math.min(c.center.x, r.p2.x));\n\tconst ny = Math.max(r.p1.y, Math.min(c.center.y, r.p2.y));\n\tconst nearestPoint = vec2(nx, ny);\n\treturn nearestPoint.dist(c.center) <= c.radius;\n}\n\nexport function testRectPolygon(r: Rect, p: Polygon): boolean {\n\treturn testPolygonPolygon(p, [\n\t\tr.p1,\n\t\tvec2(r.p2.x, r.p1.y),\n\t\tr.p2,\n\t\tvec2(r.p1.x, r.p2.y),\n\t]);\n}\n\n// TODO\nexport function testLinePoint(l: Line, pt: Vec2): boolean {\n\treturn false;\n}\n\n// TODO\nexport function testLineCircle(l: Line, c: Circle): boolean {\n\treturn false;\n}\n\nexport function testLinePolygon(l: Line, p: Polygon): boolean {\n\n\t// test if line is inside\n\tif (testPolygonPoint(p, l.p1) || testPolygonPoint(p, l.p2)) {\n\t\treturn true;\n\t}\n\n\t// test each line\n\tfor (let i = 0; i < p.length; i++) {\n\t\tconst p1 = p[i];\n\t\tconst p2 = p[(i + 1) % p.length];\n\t\tif (testLineLine(l, { p1, p2 })) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n\n}\n\nexport function testCirclePoint(c: Circle, p: Point): boolean {\n\treturn c.center.dist(p) < c.radius;\n}\n\nexport function testCircleCircle(c1: Circle, c2: Circle): boolean {\n\treturn c1.center.dist(c2.center) < c1.radius + c2.radius;\n}\n\n// TODO\nexport function testCirclePolygon(c: Circle, p: Polygon): boolean {\n\treturn false;\n}\n\nexport function testPolygonPolygon(p1: Polygon, p2: Polygon): boolean {\n\tfor (let i = 0; i < p1.length; i++) {\n\t\tconst l = {\n\t\t\tp1: p1[i],\n\t\t\tp2: p1[(i + 1) % p1.length],\n\t\t};\n\t\tif (testLinePolygon(l, p2)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n// https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html\nexport function testPolygonPoint(p: Polygon, pt: Point): boolean {\n\n\tlet c = false;\n\n\tfor (let i = 0, j = p.length - 1; i < p.length; j = i++) {\n\t\tif (\n\t\t\t((p[i].y > pt.y) != (p[j].y > pt.y))\n\t\t\t&& (pt.x < (p[j].x - p[i].x) * (pt.y - p[i].y) / (p[j].y - p[i].y) + p[i].x)\n\t\t) {\n\t\t\tc = !c;\n\t\t}\n\t}\n\n\treturn c;\n\n}\n\nexport function testPointPoint(p1: Point, p2: Point): boolean {\n\treturn p1.eq(p2);\n}\n\nexport function testAreaRect(a: Area, r: Rect): boolean {\n\tswitch (a.shape) {\n\t\tcase \"rect\": return testRectRect(r, a);\n\t\tcase \"line\": return testRectLine(r, a);\n\t\tcase \"circle\": return testRectCircle(r, a);\n\t\tcase \"polygon\": return testRectPolygon(r, a.pts);\n\t\tcase \"point\": return testRectPoint(r, a.pt);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a as Area).shape}`);\n}\n\nexport function testAreaLine(a: Area, l: Line): boolean {\n\tswitch (a.shape) {\n\t\tcase \"rect\": return testRectLine(a, l);\n\t\tcase \"line\": return Boolean(testLineLine(a, l));\n\t\tcase \"circle\": return testLineCircle(l, a);\n\t\tcase \"polygon\": return testLinePolygon(l, a.pts);\n\t\tcase \"point\": return testLinePoint(l, a.pt);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a as Area).shape}`);\n}\n\nexport function testAreaCircle(a: Area, c: Circle): boolean {\n\tswitch (a.shape) {\n\t\tcase \"rect\": return testRectCircle(a, c);\n\t\tcase \"line\": return testLineCircle(a, c);\n\t\tcase \"circle\": return testCircleCircle(a, c);\n\t\tcase \"polygon\": return testCirclePolygon(c, a.pts);\n\t\tcase \"point\": return testCirclePoint(c, a.pt);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a as Area).shape}`);\n}\n\nexport function testAreaPolygon(a: Area, p: Polygon): boolean {\n\tswitch (a.shape) {\n\t\tcase \"rect\": return testRectPolygon(a, p);\n\t\tcase \"line\": return testLinePolygon(a, p);\n\t\tcase \"circle\": return testCirclePolygon(a, p);\n\t\tcase \"polygon\": return testPolygonPolygon(p, a.pts);\n\t\tcase \"point\": return testPolygonPoint(p, a.pt);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a as Area).shape}`);\n}\n\nexport function testAreaPoint(a: Area, p: Point): boolean {\n\tswitch (a.shape) {\n\t\tcase \"rect\": return testRectPoint(a, p);\n\t\tcase \"line\": return testLinePoint(a, p);\n\t\tcase \"circle\": return testCirclePoint(a, p);\n\t\tcase \"polygon\": return testPolygonPoint(a.pts, p);\n\t\tcase \"point\": return testPointPoint(a.pt, p);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a as Area).shape}`);\n}\n\nexport function testAreaArea(a1: Area, a2: Area): boolean {\n\tswitch (a2.shape) {\n\t\tcase \"rect\": return testAreaRect(a1, a2);\n\t\tcase \"line\": return testAreaLine(a1, a2);\n\t\tcase \"circle\": return testAreaCircle(a1, a2);\n\t\tcase \"polygon\": return testAreaPolygon(a1, a2.pts);\n\t\tcase \"point\": return testAreaPoint(a1, a2.pt);\n\t}\n\tthrow new Error(`Unknown area shape: ${(a2 as Area).shape}`);\n}\n\nexport function minkDiff(r1: Rect, r2: Rect): Rect {\n\treturn {\n\t\tp1: vec2(r1.p1.x - r2.p2.x, r1.p1.y - r2.p2.y),\n\t\tp2: vec2(r1.p2.x - r2.p1.x, r1.p2.y - r2.p1.y),\n\t};\n}\n\nexport class Line {\n\tp1: Vec2;\n\tp2: Vec2;\n\tconstructor(p1: Vec2, p2: Vec2) {\n\t\tthis.p1 = p1;\n\t\tthis.p2 = p2;\n\t}\n}\n\nexport class Rect {\n\tp1: Vec2;\n\tp2: Vec2;\n\tconstructor(p1: Vec2, p2: Vec2) {\n\t\tthis.p1 = p1;\n\t\tthis.p2 = p2;\n\t}\n}\n\nexport class Circle {\n\tcenter: Vec2;\n\tradius: number;\n\tconstructor(center: Vec2, radius: number) {\n\t\tthis.center = center;\n\t\tthis.radius = radius;\n\t}\n}\n", "export default class FPSCounter {\n\n\tprivate buf: number[] = [];\n\tprivate timer: number = 0;\n\tfps: number = 0;\n\n\ttick(dt: number) {\n\n\t\tthis.buf.push(1 / dt);\n\t\tthis.timer += dt;\n\n\t\tif (this.timer >= 1) {\n\t\t\tthis.timer = 0;\n\t\t\tthis.fps = Math.round(this.buf.reduce((a, b) => a + b) / this.buf.length);\n\t\t\tthis.buf = [];\n\t\t}\n\n\t}\n\n}\n", "export default class Timer {\n\n\ttime: number\n\taction: () => void\n\tfinished: boolean = false\n\tpaused: boolean = false\n\n\tconstructor(time: number, action: () => void) {\n\t\tthis.time = time;\n\t\tthis.action = action;\n\t}\n\n\ttick(dt: number): boolean {\n\t\tif (this.finished || this.paused) return false;\n\t\tthis.time -= dt;\n\t\tif (this.time <= 0) {\n\t\t\tthis.action();\n\t\t\tthis.finished = true;\n\t\t\tthis.time = 0;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\treset(time) {\n\t\tthis.time = time;\n\t\tthis.finished = false;\n\t}\n\n}\n", "import {\n\tvec2,\n\tvec3,\n\tVec3,\n\tRect,\n\tLine,\n\tCircle,\n\tColor,\n\tVec2,\n\tMat4,\n\tQuad,\n\tRNG,\n\tquad,\n\trgb,\n\thsl2rgb,\n\trng,\n\trand,\n\trandi,\n\trandSeed,\n\tchance,\n\tchoose,\n\tclamp,\n\tlerp,\n\tmap,\n\tmapc,\n\twave,\n\ttestAreaRect,\n\ttestAreaLine,\n\ttestAreaCircle,\n\ttestAreaPolygon,\n\ttestAreaPoint,\n\ttestAreaArea,\n\ttestLineLineT,\n\ttestRectRect2,\n\ttestLineLine,\n\ttestRectRect,\n\ttestRectLine,\n\ttestRectPoint,\n\ttestPolygonPoint,\n\ttestLinePolygon,\n\ttestPolygonPolygon,\n\ttestCircleCircle,\n\ttestCirclePoint,\n\ttestRectPolygon,\n\tminkDiff,\n\tdeg2rad,\n\trad2deg,\n} from \"./math\";\n\nimport {\n\tIDList,\n\tdownloadURL,\n\tdownloadBlob,\n\tuid,\n\tdeprecate,\n\tdeprecateMsg,\n\tisDataURL,\n\tdeepEq,\n} from \"./utils\";\n\nimport {\n\tGfxShader,\n\tGfxFont,\n\tTexFilter,\n\tRenderProps,\n\tCharTransform,\n\tCharTransformFunc,\n\tTexWrap,\n\tFormattedText,\n\tFormattedChar,\n\tDrawRectOpt,\n\tDrawLineOpt,\n\tDrawLinesOpt,\n\tDrawTriangleOpt,\n\tDrawPolygonOpt,\n\tDrawCircleOpt,\n\tDrawEllipseOpt,\n\tDrawUVQuadOpt,\n\tVertex,\n\tSpriteData,\n\tSoundData,\n\tFontData,\n\tShaderData,\n\tSpriteLoadSrc,\n\tSpriteLoadOpt,\n\tSpriteAtlasData,\n\tFontLoadOpt,\n\tGfxTexData,\n\tKaboomCtx,\n\tKaboomOpt,\n\tAudioPlay,\n\tAudioPlayOpt,\n\tDrawSpriteOpt,\n\tDrawTextOpt,\n\tGameObj,\n\tEventCanceller,\n\tSceneID,\n\tSceneDef,\n\tCompList,\n\tComp,\n\tTag,\n\tKey,\n\tMouseButton,\n\tTouchID,\n\tCollision,\n\tPosComp,\n\tScaleComp,\n\tRotateComp,\n\tColorComp,\n\tOpacityComp,\n\tOrigin,\n\tOriginComp,\n\tLayerComp,\n\tZComp,\n\tFollowComp,\n\tMoveComp,\n\tOutviewCompOpt,\n\tOutviewComp,\n\tCleanupCompOpt,\n\tCleanupComp,\n\tAreaCompOpt,\n\tAreaComp,\n\tArea,\n\tSpriteComp,\n\tSpriteCompOpt,\n\tGfxTexture,\n\tSpriteAnimPlayOpt,\n\tTextComp,\n\tTextCompOpt,\n\tRectComp,\n\tRectCompOpt,\n\tUVQuadComp,\n\tCircleComp,\n\tOutlineComp,\n\tTimerComp,\n\tBodyComp,\n\tBodyCompOpt,\n\tUniform,\n\tShaderComp,\n\tSolidComp,\n\tFixedComp,\n\tStayComp,\n\tHealthComp,\n\tLifespanComp,\n\tLifespanCompOpt,\n\tStateComp,\n\tDebug,\n\tKaboomPlugin,\n\tMergeObj,\n\tLevel,\n\tLevelOpt,\n\tCursor,\n\tRecording,\n\tKaboom,\n} from \"./types\";\n\nimport FPSCounter from \"./fps\";\nimport Timer from \"./timer\";\n\n// @ts-ignore\nimport apl386Src from \"./assets/apl386.png\";\n// @ts-ignore\nimport apl386oSrc from \"./assets/apl386o.png\";\n// @ts-ignore\nimport sinkSrc from \"./assets/sink.png\";\n// @ts-ignore\nimport sinkoSrc from \"./assets/sinko.png\";\n// @ts-ignore\nimport beanSrc from \"./assets/bean.png\";\n// @ts-ignore\nimport burpBytes from \"./assets/burp.mp3\";\n// @ts-ignore\nimport kaSrc from \"./assets/ka.png\";\n// @ts-ignore\nimport boomSrc from \"./assets/boom.png\";\n\ntype ButtonState =\n\t\"up\"\n\t| \"pressed\"\n\t| \"rpressed\"\n\t| \"down\"\n\t| \"released\"\n\t;\n\ntype DrawTextureOpt = RenderProps & {\n\ttex: GfxTexture,\n\twidth?: number,\n\theight?: number,\n\ttiled?: boolean,\n\tflipX?: boolean,\n\tflipY?: boolean,\n\tquad?: Quad,\n\torigin?: Origin | Vec2,\n}\n\ninterface GfxTexOpt {\n\tfilter?: TexFilter,\n\twrap?: TexWrap,\n}\n\n// translate these key names to a simpler version\nconst KEY_ALIAS = {\n\t\"ArrowLeft\": \"left\",\n\t\"ArrowRight\": \"right\",\n\t\"ArrowUp\": \"up\",\n\t\"ArrowDown\": \"down\",\n\t\" \": \"space\",\n};\n\n// according to https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\nconst MOUSE_BUTTONS = [\n\t\"left\",\n\t\"middle\",\n\t\"right\",\n\t\"back\",\n\t\"forward\",\n];\n\n// don't trigger browser default event when these keys are pressed\nconst PREVENT_DEFAULT_KEYS = [\n\t\"space\",\n\t\"left\",\n\t\"right\",\n\t\"up\",\n\t\"down\",\n\t\"tab\",\n\t\"f1\",\n\t\"f2\",\n\t\"f3\",\n\t\"f4\",\n\t\"f5\",\n\t\"f6\",\n\t\"f7\",\n\t\"f8\",\n\t\"f9\",\n\t\"f10\",\n\t\"f11\",\n\t\"s\",\n];\n\n// some default charsets for loading bitmap fonts\nconst ASCII_CHARS = \" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\";\nconst CP437_CHARS = \" \u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\u00B6\u00A7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\";\n\n// audio gain range\nconst MIN_GAIN = 0;\nconst MAX_GAIN = 3;\n\n// audio speed range\nconst MIN_SPEED = 0;\nconst MAX_SPEED = 3;\n\n// audio detune range\nconst MIN_DETUNE = -1200;\nconst MAX_DETUNE = 1200;\n\nconst DEF_ORIGIN = \"topleft\";\nconst DEF_GRAVITY = 1600;\nconst QUEUE_COUNT = 65536;\nconst BG_GRID_SIZE = 64;\n\nconst DEF_FONT = \"apl386o\";\nconst DBG_FONT = \"sink\";\n\n// vertex format stride (vec3 pos, vec2 uv, vec4 color)\nconst STRIDE = 9;\n\n// vertex shader template, replace {{user}} with user vertex shader code\nconst VERT_TEMPLATE = `\nattribute vec3 a_pos;\nattribute vec2 a_uv;\nattribute vec4 a_color;\n\nvarying vec3 v_pos;\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvec4 def_vert() {\n\treturn vec4(a_pos, 1.0);\n}\n\n{{user}}\n\nvoid main() {\n\tvec4 pos = vert(a_pos, a_uv, a_color);\n\tv_pos = a_pos;\n\tv_uv = a_uv;\n\tv_color = a_color;\n\tgl_Position = pos;\n}\n`;\n\n// fragment shader template, replace {{user}} with user fragment shader code\nconst FRAG_TEMPLATE = `\nprecision mediump float;\n\nvarying vec3 v_pos;\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nuniform sampler2D u_tex;\n\nvec4 def_frag() {\n\treturn v_color * texture2D(u_tex, v_uv);\n}\n\n{{user}}\n\nvoid main() {\n\tgl_FragColor = frag(v_pos, v_uv, v_color, u_tex);\n\tif (gl_FragColor.a == 0.0) {\n\t\tdiscard;\n\t}\n}\n`;\n\n// default {{user}} vertex shader code\nconst DEF_VERT = `\nvec4 vert(vec3 pos, vec2 uv, vec4 color) {\n\treturn def_vert();\n}\n`;\n\n// default {{user}} fragment shader code\nconst DEF_FRAG = `\nvec4 frag(vec3 pos, vec2 uv, vec4 color, sampler2D tex) {\n\treturn def_frag();\n}\n`;\n\nconst COMP_DESC = new Set([\n\t\"id\",\n\t\"require\",\n]);\n\nconst COMP_EVENTS = new Set([\n\t\"add\",\n\t\"load\",\n\t\"update\",\n\t\"draw\",\n\t\"destroy\",\n\t\"inspect\",\n]);\n\n// transform the button state to the next state\n// e.g. a button might become \"pressed\" one frame, and it should become \"down\" next frame\nfunction processButtonState(s: ButtonState): ButtonState {\n\tif (s === \"pressed\" || s === \"rpressed\") {\n\t\treturn \"down\";\n\t}\n\tif (s === \"released\") {\n\t\treturn \"up\";\n\t}\n\treturn s;\n}\n\n// wrappers around full screen functions to work across browsers\nfunction enterFullscreen(el: HTMLElement) {\n\tif (el.requestFullscreen) el.requestFullscreen();\n\t// @ts-ignore\n\telse if (el.webkitRequestFullscreen) el.webkitRequestFullscreen();\n};\n\nfunction exitFullscreen() {\n\tif (document.exitFullscreen) document.exitFullscreen();\n\t// @ts-ignore\n\telse if (document.webkitExitFullScreen) document.webkitExitFullScreen();\n};\n\nfunction getFullscreenElement(): Element | void {\n\treturn document.fullscreenElement\n\t\t// @ts-ignore\n\t\t|| document.webkitFullscreenElement\n\t\t;\n};\n\n// convert origin string to a vec2 offset\nfunction originPt(orig: Origin | Vec2): Vec2 {\n\tswitch (orig) {\n\t\tcase \"topleft\": return vec2(-1, -1);\n\t\tcase \"top\": return vec2(0, -1);\n\t\tcase \"topright\": return vec2(1, -1);\n\t\tcase \"left\": return vec2(-1, 0);\n\t\tcase \"center\": return vec2(0, 0);\n\t\tcase \"right\": return vec2(1, 0);\n\t\tcase \"botleft\": return vec2(-1, 1);\n\t\tcase \"bot\": return vec2(0, 1);\n\t\tcase \"botright\": return vec2(1, 1);\n\t\tdefault: return orig;\n\t}\n}\n\nfunction createEmptyAudioBuffer() {\n\treturn new AudioBuffer({\n\t\tlength: 1,\n\t\tnumberOfChannels: 1,\n\t\tsampleRate: 44100\n\t});\n}\n\n// only exports one kaboom() which contains all the state\nexport default (gopt: KaboomOpt = {}): KaboomCtx => {\n\nconst app = (() => {\n\n\tconst root = gopt.root ?? document.body;\n\n\t// if root is not defined (which falls back to <body>) we assume user is using kaboom on a clean page, and modify <body> to better fit a full screen canvas\n\tif (root === document.body) {\n\t\tdocument.body.style[\"width\"] = \"100%\";\n\t\tdocument.body.style[\"height\"] = \"100%\";\n\t\tdocument.body.style[\"margin\"] = \"0px\";\n\t\tdocument.documentElement.style[\"width\"] = \"100%\";\n\t\tdocument.documentElement.style[\"height\"] = \"100%\";\n\t}\n\n\t// create a <canvas> if user didn't provide one\n\tconst canvas = gopt.canvas ?? (() => {\n\t\tconst canvas = document.createElement(\"canvas\");\n\t\troot.appendChild(canvas);\n\t\treturn canvas;\n\t})();\n\n\t// global pixel scale\n\tconst gscale = gopt.scale ?? 1;\n\n\t// adjust canvas size according to user size / viewport settings\n\tif (gopt.width && gopt.height && !gopt.stretch && !gopt.letterbox) {\n\t\tcanvas.width = gopt.width * gscale;\n\t\tcanvas.height = gopt.height * gscale;\n\t} else {\n\t\tcanvas.width = canvas.parentElement.offsetWidth;\n\t\tcanvas.height = canvas.parentElement.offsetHeight;\n\t}\n\n\t// canvas css styles\n\tconst styles = [\n\t\t\"outline: none\",\n\t\t\"cursor: default\",\n\t];\n\n\tif (gopt.crisp) {\n\t\tstyles.push(\"image-rendering: pixelated\");\n\t\tstyles.push(\"image-rendering: crisp-edges\");\n\t}\n\n\t// TODO: .style is supposed to be readonly? alternative?\n\t// @ts-ignore\n\tcanvas.style = styles.join(\";\");\n\n\t// make canvas focusable\n\tcanvas.setAttribute(\"tabindex\", \"0\");\n\n\t// create webgl context\n\tconst gl = canvas\n\t\t.getContext(\"webgl\", {\n\t\t\tantialias: true,\n\t\t\tdepth: true,\n\t\t\tstencil: true,\n\t\t\talpha: true,\n\t\t\tpreserveDrawingBuffer: true,\n\t\t});\n\n\treturn {\n\n\t\tcanvas: canvas,\n\t\tscale: gscale,\n\t\tgl: gl,\n\n\t\t// keep track of all button states\n\t\tkeyStates: {} as Record<Key, ButtonState>,\n\t\tmouseStates: {} as Record<MouseButton, ButtonState>,\n\n\t\t// input states from last frame, should reset every frame\n\t\tcharInputted: [],\n\t\tisMouseMoved: false,\n\t\tisKeyPressed: false,\n\t\tisKeyPressedRepeat: false,\n\t\tisKeyReleased: false,\n\t\tmousePos: vec2(0, 0),\n\t\tmouseDeltaPos: vec2(0, 0),\n\n\t\t// total time elapsed\n\t\ttime: 0,\n\t\t// real total time elapsed (including paused time)\n\t\trealTime: 0,\n\t\t// if we should skip next dt, to prevent the massive dt surge if user switch to another tab for a while and comeback\n\t\tskipTime: false,\n\t\t// how much time last frame took\n\t\tdt: 0.0,\n\t\t// total frames elapsed\n\t\tnumFrames: 0,\n\n\t\t// if we're on a touch device\n\t\tisTouch: (\"ontouchstart\" in window) || navigator.maxTouchPoints > 0,\n\n\t\t// requestAnimationFrame id\n\t\tloopID: null,\n\t\t// if our game loop is currently stopped / paused\n\t\tstopped: false,\n\t\tpaused: false,\n\n\t\t// TODO: take fps counter out pure\n\t\tfpsCounter: new FPSCounter(),\n\n\t\t// if we finished loading all assets\n\t\tloaded: false,\n\n\t};\n\n})();\n\nconst gfx = (() => {\n\n\tconst gl = app.gl;\n\tconst defShader = makeShader(DEF_VERT, DEF_FRAG);\n\n\t// a 1x1 white texture to draw raw shapes like rectangles and polygons\n\t// we use a texture for those so we can use only 1 pipeline for drawing sprites + shapes\n\tconst emptyTex = makeTex(\n\t\tnew ImageData(new Uint8ClampedArray([ 255, 255, 255, 255, ]), 1, 1)\n\t);\n\n\tconst c = gopt.background ?? rgb(0, 0, 0);\n\n\tif (gopt.background) {\n\t\tconst c = Color.fromArray(gopt.background);\n\t\tgl.clearColor(c.r / 255, c.g / 255, c.b / 255, 1);\n\t}\n\n\tgl.enable(gl.BLEND);\n\tgl.enable(gl.SCISSOR_TEST);\n\tgl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n\n\t// we only use one vertex and index buffer that batches all draw calls\n\tconst vbuf = gl.createBuffer();\n\n\tgl.bindBuffer(gl.ARRAY_BUFFER, vbuf);\n\t// vec3 pos\n\tgl.vertexAttribPointer(0, 3, gl.FLOAT, false, STRIDE * 4, 0);\n\tgl.enableVertexAttribArray(0);\n\t// vec2 uv\n\tgl.vertexAttribPointer(1, 2, gl.FLOAT, false, STRIDE * 4, 12);\n\tgl.enableVertexAttribArray(1);\n\t// vec4 color\n\tgl.vertexAttribPointer(2, 4, gl.FLOAT, false, STRIDE * 4, 20);\n\tgl.enableVertexAttribArray(2);\n\tgl.bufferData(gl.ARRAY_BUFFER, QUEUE_COUNT * 4, gl.DYNAMIC_DRAW);\n\tgl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n\tconst ibuf = gl.createBuffer();\n\n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibuf);\n\tgl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUEUE_COUNT * 2, gl.DYNAMIC_DRAW);\n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n\n\t// a checkerboard texture used for the default background\n\tconst bgTex = makeTex(\n\t\tnew ImageData(new Uint8ClampedArray([\n\t\t\t128, 128, 128, 255,\n\t\t\t190, 190, 190, 255,\n\t\t\t190, 190, 190, 255,\n\t\t\t128, 128, 128, 255,\n\t\t]), 2, 2), {\n\t\t\twrap: \"repeat\",\n\t\t\tfilter: \"nearest\",\n\t\t},\n\t);\n\n\treturn {\n\n\t\t// keep track of how many draw calls we're doing this frame\n\t\tdrawCalls: 0,\n\t\t// how many draw calls we're doing last frame, this is the number we give to users\n\t\tlastDrawCalls: 0,\n\n\t\t// gfx states\n\t\tdefShader: defShader,\n\t\tcurShader: defShader,\n\t\tdefTex: emptyTex,\n\t\tcurTex: emptyTex,\n\t\tcurUniform: {},\n\t\tvbuf: vbuf,\n\t\tibuf: ibuf,\n\n\t\t// local vertex / index buffer queue\n\t\tvqueue: [],\n\t\tiqueue: [],\n\n\t\ttransform: new Mat4(),\n\t\ttransformStack: [],\n\n\t\tbgTex: bgTex,\n\n\t\twidth: gopt.width,\n\t\theight: gopt.height,\n\n\t\tviewport: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth: gl.drawingBufferWidth,\n\t\t\theight: gl.drawingBufferHeight,\n\t\t},\n\n\t};\n\n})();\n\nupdateViewport();\n\nconst audio = (() => {\n\n\t// TODO: handle when audio context is unavailable\n\tconst ctx = new (window.AudioContext || (window as any).webkitAudioContext)() as AudioContext\n\tconst masterNode = ctx.createGain();\n\tmasterNode.connect(ctx.destination);\n\n\t// by default browsers can only load audio async, we don't deal with that and just start with an empty audio buffer\n\tconst burpSnd = {\n\t\tbuf: createEmptyAudioBuffer(),\n\t};\n\n\t// load that burp sound\n\tctx.decodeAudioData(burpBytes.buffer.slice(0), (buf) => {\n\t\tburpSnd.buf = buf;\n\t}, () => {\n\t\tthrow new Error(\"Failed to load burp.\")\n\t});\n\n\treturn {\n\t\tctx,\n\t\tmasterNode,\n\t\tburpSnd,\n\t};\n\n})();\n\nconst assets = {\n\n\t// keep track of how many assets are loading / loaded, for calculaating progress\n\tnumLoading: 0,\n\tnumLoaded: 0,\n\n\t// prefix for when loading from a url\n\turlPrefix: \"\",\n\n\t// asset holders\n\tsprites: {},\n\tsounds: {},\n\tshaders: {},\n\tfonts: {},\n\n};\n\nconst game = {\n\n\t// event callbacks\n\tevents: {},\n\tobjEvents: {},\n\n\t// root game object\n\t// these transforms are used as camera\n\troot: make([]),\n\n\ttimers: new IDList<Timer>(),\n\n\t// misc\n\tlayers: {},\n\tdefLayer: null,\n\tgravity: DEF_GRAVITY,\n\ton<F>(ev: string, cb: F): EventCanceller {\n\t\tif (!this.events[ev]) {\n\t\t\tthis.events[ev] = new IDList();\n\t\t}\n\t\treturn this.events[ev].pushd(cb);\n\t},\n\ttrigger(ev: string, ...args) {\n\t\tif (this.events[ev]) {\n\t\t\tthis.events[ev].forEach((cb) => cb(...args));\n\t\t}\n\t},\n\tscenes: {},\n\n\t// on screen log\n\tlogs: [],\n\n\t// camera\n\tcam: {\n\t\tpos: center(),\n\t\tscale: vec2(1),\n\t\tangle: 0,\n\t\tshake: 0,\n\t\ttransform: new Mat4(),\n\t},\n\n}\n\n// wrap individual loaders with global loader counter, for stuff like progress bar\nfunction load<T>(prom: Promise<T>): Promise<T> {\n\n\tassets.numLoading++;\n\n\t// wrapping another layer of promise because we are catching errors here internally and we also want users be able to catch errors, however only one catch is allowed per promise chain\n\treturn new Promise((resolve, reject) => {\n\t\tprom\n\t\t\t.then(resolve)\n\t\t\t.catch((err) => {\n\t\t\t\tdebug.error(err);\n\t\t\t\treject(err);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassets.numLoading--;\n\t\t\t\tassets.numLoaded++;\n\t\t\t});\n\t}) as Promise<T>;\n\n}\n\n// get current load progress\nfunction loadProgress(): number {\n\treturn assets.numLoaded / (assets.numLoading + assets.numLoaded);\n}\n\n// global load path prefix\nfunction loadRoot(path?: string): string {\n\tif (path !== undefined) {\n\t\tassets.urlPrefix = path;\n\t}\n\treturn assets.urlPrefix;\n}\n\n// wrapper around fetch() that applies urlPrefix and basic error handling\nfunction fetchURL(path: string) {\n\tconst url = assets.urlPrefix + path;\n\treturn fetch(url)\n\t\t.then((res) => {\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch ${url}`);\n\t\t\t}\n\t\t\treturn res;\n\t\t});\n}\n\n// wrapper around image loader to get a Promise\nfunction loadImg(src: string): Promise<HTMLImageElement> {\n\tconst img = new Image();\n\timg.src = isDataURL(src) ? src : assets.urlPrefix + src;\n\timg.crossOrigin = \"anonymous\";\n\treturn new Promise<HTMLImageElement>((resolve, reject) => {\n\t\timg.onload = () => resolve(img);\n\t\t// TODO: truncate for long dataurl src\n\t\timg.onerror = () => reject(`Failed to load image from \"${src}\"`);\n\t});\n}\n\n// TODO: support SpriteLoadSrc\nfunction loadFont(\n\tname: string | null,\n\tsrc: string,\n\tgw: number,\n\tgh: number,\n\topt: FontLoadOpt = {},\n): Promise<FontData> {\n\treturn load(loadImg(src)\n\t\t.then((img) => {\n\t\t\tconst font = makeFont(\n\t\t\t\tmakeTex(img, opt),\n\t\t\t\tgw,\n\t\t\t\tgh,\n\t\t\t\topt.chars ?? ASCII_CHARS\n\t\t\t);\n\t\t\tif (name) {\n\t\t\t\tassets.fonts[name] = font;\n\t\t\t}\n\t\t\treturn font;\n\t\t})\n\t);\n}\n\nfunction getSprite(name: string): SpriteData | null {\n\treturn assets.sprites[name] ?? null;\n}\n\nfunction getSound(name: string): SoundData | null {\n\treturn assets.sounds[name] ?? null;\n}\n\nfunction getFont(name: string): FontData | null {\n\treturn assets.fonts[name] ?? null;\n}\n\nfunction getShader(name: string): ShaderData | null {\n\treturn assets.shaders[name] ?? null;\n}\n\n// get an array of frames based on configuration on how to slice the image\nfunction slice(x = 1, y = 1, dx = 0, dy = 0, w = 1, h = 1): Quad[] {\n\tconst frames = [];\n\tconst qw = w / x;\n\tconst qh = h / y;\n\tfor (let j = 0; j < y; j++) {\n\t\tfor (let i = 0; i < x; i++) {\n\t\t\tframes.push(new Quad(\n\t\t\t\tdx + i * qw,\n\t\t\t\tdy + j * qh,\n\t\t\t\tqw,\n\t\t\t\tqh,\n\t\t\t));\n\t\t}\n\t}\n\treturn frames;\n}\n\nfunction loadSpriteAtlas(\n\tsrc: SpriteLoadSrc,\n\tdata: SpriteAtlasData | string\n): Promise<Record<string, SpriteData>> {\n\tif (typeof data === \"string\") {\n\t\t// TODO: this adds a new loader asyncly\n\t\treturn load(fetchURL(data)\n\t\t\t.then((res) => res.json())\n\t\t\t.then((data2) => loadSpriteAtlas(src, data2)));\n\t}\n\treturn load(loadSprite(null, src).then((atlas) => {\n\t\tconst map = {};\n\t\tconst w = atlas.tex.width;\n\t\tconst h = atlas.tex.height;\n\t\tfor (const name in data) {\n\t\t\tconst info = data[name];\n\t\t\tconst spr = {\n\t\t\t\ttex: atlas.tex,\n\t\t\t\tframes: slice(info.sliceX, info.sliceY, info.x / w, info.y / h, info.width / w, info.height / h),\n\t\t\t\tanims: info.anims,\n\t\t\t}\n\t\t\tassets.sprites[name] = spr;\n\t\t\tmap[name] = spr;\n\t\t}\n\t\treturn map;\n\t}));\n}\n\n// synchronously load sprite from local pixel data\nfunction loadRawSprite(\n\tname: string | null,\n\tsrc: GfxTexData,\n\topt: SpriteLoadOpt = {}\n) {\n\n\tconst tex = makeTex(src, opt);\n\tconst frames = slice(opt.sliceX || 1, opt.sliceY || 1);\n\n\tconst sprite = {\n\t\ttex: tex,\n\t\tframes: frames,\n\t\tanims: opt.anims || {},\n\t};\n\n\tif (name) {\n\t\tassets.sprites[name] = sprite;\n\t}\n\n\treturn sprite;\n\n}\n\n// load a sprite to asset manager\nfunction loadSprite(\n\tname: string | null,\n\tsrc: SpriteLoadSrc,\n\topt: SpriteLoadOpt = {\n\t\tsliceX: 1,\n\t\tsliceY: 1,\n\t\tanims: {},\n\t},\n): Promise<SpriteData> {\n\n\treturn load(new Promise<SpriteData>((resolve, reject) => {\n\n\t\tif (!src) {\n\t\t\treturn reject(`Expected sprite src for \"${name}\"`);\n\t\t}\n\n\t\t// from url\n\t\tif (typeof(src) === \"string\") {\n\t\t\tloadImg(src)\n\t\t\t\t.then((img) => resolve(loadRawSprite(name, img, opt)))\n\t\t\t\t.catch(reject);\n\t\t} else {\n\t\t\tresolve(loadRawSprite(name, src, opt));\n\t\t}\n\n\t}));\n\n}\n\n// TODO: accept raw json\nfunction loadPedit(name: string, src: string): Promise<SpriteData> {\n\n\treturn load(new Promise<SpriteData>((resolve, reject) => {\n\n\t\tfetchURL(src)\n\t\t\t.then((res) => res.json())\n\t\t\t.then(async (data) => {\n\n\t\t\t\tconst images = await Promise.all(data.frames.map(loadImg));\n\t\t\t\tconst canvas = document.createElement(\"canvas\");\n\t\t\t\tcanvas.width = data.width;\n\t\t\t\tcanvas.height = data.height * data.frames.length;\n\n\t\t\t\tconst ctx = canvas.getContext(\"2d\");\n\n\t\t\t\timages.forEach((img: HTMLImageElement, i) => {\n\t\t\t\t\tctx.drawImage(img, 0, i * data.height);\n\t\t\t\t});\n\n\t\t\t\treturn loadSprite(name, canvas, {\n\t\t\t\t\tsliceY: data.frames.length,\n\t\t\t\t\tanims: data.anims,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t;\n\n\t}));\n\n}\n\n// TODO: accept raw json\nfunction loadAseprite(\n\tname: string | null,\n\timgSrc: SpriteLoadSrc,\n\tjsonSrc: string\n): Promise<SpriteData> {\n\n\treturn load(new Promise<SpriteData>((resolve, reject) => {\n\n\t\tloadSprite(name, imgSrc)\n\t\t\t.then((sprite: SpriteData) => {\n\t\t\t\tfetchURL(jsonSrc)\n\t\t\t\t\t.then((res) => res.json())\n\t\t\t\t\t.then((data) => {\n\t\t\t\t\t\tconst size = data.meta.size;\n\t\t\t\t\t\tsprite.frames = data.frames.map((f: any) => {\n\t\t\t\t\t\t\treturn new Quad(\n\t\t\t\t\t\t\t\tf.frame.x / size.w,\n\t\t\t\t\t\t\t\tf.frame.y / size.h,\n\t\t\t\t\t\t\t\tf.frame.w / size.w,\n\t\t\t\t\t\t\t\tf.frame.h / size.h,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfor (const anim of data.meta.frameTags) {\n\t\t\t\t\t\t\tif (anim.from === anim.to) {\n\t\t\t\t\t\t\t\tsprite.anims[anim.name] = anim.from\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsprite.anims[anim.name] = {\n\t\t\t\t\t\t\t\t\tfrom: anim.from,\n\t\t\t\t\t\t\t\t\tto: anim.to,\n\t\t\t\t\t\t\t\t\t// TODO: let users define these\n\t\t\t\t\t\t\t\t\tspeed: 10,\n\t\t\t\t\t\t\t\t\tloop: true,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresolve(sprite);\n\t\t\t\t\t})\n\t\t\t\t\t.catch(reject)\n\t\t\t\t\t;\n\t\t\t})\n\t\t\t.catch(reject);\n\n\t}));\n\n}\n\nfunction loadShader(\n\tname: string | null,\n\tvert?: string,\n\tfrag?: string,\n\tisUrl: boolean = false,\n): Promise<ShaderData> {\n\n\tfunction loadRawShader(\n\t\tname: string | null,\n\t\tvert: string | null,\n\t\tfrag: string | null,\n\t): ShaderData {\n\t\tconst shader = makeShader(vert, frag);\n\t\tif (name) {\n\t\t\tassets.shaders[name] = shader;\n\t\t}\n\t\treturn shader;\n\t}\n\n\treturn load(new Promise<ShaderData>((resolve, reject) => {\n\n\t\tif (!vert && !frag) {\n\t\t\treturn reject(\"no shader\");\n\t\t}\n\n\t\tfunction resolveUrl(url?: string) {\n\t\t\treturn url ?\n\t\t\t\tfetchURL(url)\n\t\t\t\t\t.then((res) => res.text())\n\t\t\t\t\t.catch(reject)\n\t\t\t\t: new Promise((r) => r(null));\n\t\t}\n\n\t\tif (isUrl) {\n\t\t\tPromise.all([resolveUrl(vert), resolveUrl(frag)])\n\t\t\t\t.then(([vcode, fcode]: [string | null, string | null]) => {\n\t\t\t\t\tresolve(loadRawShader(name, vcode, fcode));\n\t\t\t\t})\n\t\t\t\t.catch(reject);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tresolve(loadRawShader(name, vert, frag));\n\t\t\t} catch (err) {\n\t\t\t\treject(err);\n\t\t\t}\n\t\t}\n\n\t}));\n\n}\n\n// TODO: accept dataurl\n// load a sound to asset manager\nfunction loadSound(\n\tname: string | null,\n\tsrc: string,\n): Promise<SoundData> {\n\n\treturn load(new Promise<SoundData>((resolve, reject) => {\n\n\t\tif (!src) {\n\t\t\treturn reject(`expected sound src for \"${name}\"`);\n\t\t}\n\n\t\t// from url\n\t\tif (typeof(src) === \"string\") {\n\t\t\tfetchURL(src)\n\t\t\t\t.then((res) => res.arrayBuffer())\n\t\t\t\t.then((data) => {\n\t\t\t\t\treturn new Promise((resolve2, reject2) =>\n\t\t\t\t\t\taudio.ctx.decodeAudioData(data, resolve2, reject2)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.then((buf: AudioBuffer) => {\n\t\t\t\t\tconst snd = {\n\t\t\t\t\t\tbuf: buf,\n\t\t\t\t\t}\n\t\t\t\t\tif (name) {\n\t\t\t\t\t\tassets.sounds[name] = snd;\n\t\t\t\t\t}\n\t\t\t\t\tresolve(snd);\n\t\t\t\t})\n\t\t\t\t.catch(reject);\n\t\t}\n\n\t}));\n\n}\n\nfunction loadBean(name: string = \"bean\"): Promise<SpriteData> {\n\treturn loadSprite(name, beanSrc);\n}\n\n// get / set master volume\nfunction volume(v?: number): number {\n\tif (v !== undefined) {\n\t\taudio.masterNode.gain.value = clamp(v, MIN_GAIN, MAX_GAIN);\n\t}\n\treturn audio.masterNode.gain.value;\n}\n\n// plays a sound, returns a control handle\nfunction play(\n\tsrc: SoundData | string,\n\topt: AudioPlayOpt = {\n\t\tloop: false,\n\t\tvolume: 1,\n\t\tspeed: 1,\n\t\tdetune: 0,\n\t\tseek: 0,\n\t},\n): AudioPlay {\n\n\t// TODO: clean?\n\tif (typeof src === \"string\") {\n\n\t\tconst pb = play({\n\t\t\tbuf: createEmptyAudioBuffer(),\n\t\t});\n\n\t\tonLoad(() => {\n\t\t\tconst snd = assets.sounds[src];\n\t\t\tif (!snd) {\n\t\t\t\tthrow new Error(`Sound not found: \"${src}\"`);\n\t\t\t}\n\t\t\tconst pb2 = play(snd, opt);\n\t\t\tfor (const k in pb2) {\n\t\t\t\tpb[k] = pb2[k];\n\t\t\t}\n\t\t});\n\n\t\treturn pb;\n\n\t}\n\n\tconst ctx = audio.ctx;\n\tlet stopped = false;\n\tlet srcNode = ctx.createBufferSource();\n\n\tsrcNode.buffer = src.buf;\n\tsrcNode.loop = opt.loop ? true : false;\n\n\tconst gainNode = ctx.createGain();\n\n\tsrcNode.connect(gainNode);\n\tgainNode.connect(audio.masterNode);\n\n\tconst pos = opt.seek ?? 0;\n\n\tsrcNode.start(0, pos);\n\n\tlet startTime = ctx.currentTime - pos;\n\tlet stopTime: number | null = null;\n\n\tconst handle = {\n\n\t\tstop() {\n\t\t\tif (stopped) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.pause();\n\t\t\tstartTime = ctx.currentTime;\n\t\t},\n\n\t\tplay(seek?: number) {\n\n\t\t\tif (!stopped) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldNode = srcNode;\n\n\t\t\tsrcNode = ctx.createBufferSource();\n\t\t\tsrcNode.buffer = oldNode.buffer;\n\t\t\tsrcNode.loop = oldNode.loop;\n\t\t\tsrcNode.playbackRate.value = oldNode.playbackRate.value;\n\n\t\t\tif (srcNode.detune) {\n\t\t\t\tsrcNode.detune.value = oldNode.detune.value;\n\t\t\t}\n\n\t\t\tsrcNode.connect(gainNode);\n\n\t\t\tconst pos = seek ?? this.time();\n\n\t\t\tsrcNode.start(0, pos);\n\t\t\tstartTime = ctx.currentTime - pos;\n\t\t\tstopped = false;\n\t\t\tstopTime = null;\n\n\t\t},\n\n\t\tpause() {\n\t\t\tif (stopped) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsrcNode.stop();\n\t\t\tstopped = true;\n\t\t\tstopTime = ctx.currentTime;\n\t\t},\n\n\t\tisPaused(): boolean {\n\t\t\treturn stopped;\n\t\t},\n\n\t\tpaused(): boolean {\n\t\t\tdeprecateMsg(\"paused()\", \"isPaused()\");\n\t\t\treturn this.isPaused();\n\t\t},\n\n\t\tisStopped(): boolean {\n\t\t\treturn stopped;\n\t\t},\n\n\t\tstopped(): boolean {\n\t\t\tdeprecateMsg(\"stopped()\", \"isStopped()\");\n\t\t\treturn this.isStopped();\n\t\t},\n\n\t\t// TODO: affect time()\n\t\tspeed(val?: number): number {\n\t\t\tif (val !== undefined) {\n\t\t\t\tsrcNode.playbackRate.value = clamp(val, MIN_SPEED, MAX_SPEED);\n\t\t\t}\n\t\t\treturn srcNode.playbackRate.value;\n\t\t},\n\n\t\tdetune(val?: number): number {\n\t\t\tif (!srcNode.detune) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (val !== undefined) {\n\t\t\t\tsrcNode.detune.value = clamp(val, MIN_DETUNE, MAX_DETUNE);\n\t\t\t}\n\t\t\treturn srcNode.detune.value;\n\t\t},\n\n\t\tvolume(val?: number): number {\n\t\t\tif (val !== undefined) {\n\t\t\t\tgainNode.gain.value = clamp(val, MIN_GAIN, MAX_GAIN);\n\t\t\t}\n\t\t\treturn gainNode.gain.value;\n\t\t},\n\n\t\tloop() {\n\t\t\tsrcNode.loop = true;\n\t\t},\n\n\t\tunloop() {\n\t\t\tsrcNode.loop = false;\n\t\t},\n\n\t\tduration(): number {\n\t\t\treturn src.buf.duration;\n\t\t},\n\n\t\ttime(): number {\n\t\t\tif (stopped) {\n\t\t\t\treturn stopTime - startTime;\n\t\t\t} else {\n\t\t\t\treturn ctx.currentTime - startTime;\n\t\t\t}\n\t\t},\n\n\t};\n\n\thandle.speed(opt.speed);\n\thandle.detune(opt.detune);\n\thandle.volume(opt.volume);\n\n\treturn handle;\n\n}\n\n// core kaboom logic\nfunction burp(opt?: AudioPlayOpt): AudioPlay {\n\treturn play(audio.burpSnd, opt);\n}\n\n// TODO: take these webgl structures out pure\nfunction makeTex(\n\tdata: GfxTexData,\n\topt: GfxTexOpt = {}\n): GfxTexture {\n\n\tconst gl = app.gl;\n\tconst id = gl.createTexture();\n\n\tgl.bindTexture(gl.TEXTURE_2D, id);\n\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);\n\n\tconst filter = (() => {\n\t\tswitch (opt.filter ?? gopt.texFilter) {\n\t\t\tcase \"linear\": return gl.LINEAR;\n\t\t\tcase \"nearest\": return gl.NEAREST;\n\t\t\tdefault: return gl.NEAREST;\n\t\t}\n\t})();\n\n\tconst wrap = (() => {\n\t\tswitch (opt.wrap) {\n\t\t\tcase \"repeat\": return gl.REPEAT;\n\t\t\tcase \"clampToEdge\": return gl.CLAMP_TO_EDGE;\n\t\t\tdefault: return gl.CLAMP_TO_EDGE;\n\t\t}\n\t})();\n\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);\n\tgl.bindTexture(gl.TEXTURE_2D, null);\n\n\treturn {\n\t\twidth: data.width,\n\t\theight: data.height,\n\t\tbind() {\n\t\t\tgl.bindTexture(gl.TEXTURE_2D, id);\n\t\t},\n\t\tunbind() {\n\t\t\tgl.bindTexture(gl.TEXTURE_2D, null);\n\t\t},\n\t};\n\n}\n\nfunction makeShader(\n\tvertSrc: string | null = DEF_VERT,\n\tfragSrc: string | null = DEF_FRAG,\n): GfxShader {\n\n\tconst gl = app.gl;\n\tlet msg;\n\tconst vcode = VERT_TEMPLATE.replace(\"{{user}}\", vertSrc ?? DEF_VERT);\n\tconst fcode = FRAG_TEMPLATE.replace(\"{{user}}\", fragSrc ?? DEF_FRAG);\n\tconst vertShader = gl.createShader(gl.VERTEX_SHADER);\n\tconst fragShader = gl.createShader(gl.FRAGMENT_SHADER);\n\n\tgl.shaderSource(vertShader, vcode);\n\tgl.shaderSource(fragShader, fcode);\n\tgl.compileShader(vertShader);\n\tgl.compileShader(fragShader);\n\n\tif ((msg = gl.getShaderInfoLog(vertShader))) {\n\t\tthrow new Error(msg);\n\t}\n\n\tif ((msg = gl.getShaderInfoLog(fragShader))) {\n\t\tthrow new Error(msg);\n\t}\n\n\tconst id = gl.createProgram();\n\n\tgl.attachShader(id, vertShader);\n\tgl.attachShader(id, fragShader);\n\n\tgl.bindAttribLocation(id, 0, \"a_pos\");\n\tgl.bindAttribLocation(id, 1, \"a_uv\");\n\tgl.bindAttribLocation(id, 2, \"a_color\");\n\n\tgl.linkProgram(id);\n\n\tif ((msg = gl.getProgramInfoLog(id))) {\n\t\t// for some reason on safari it always has a \"\\n\" msg\n\t\tif (msg !== \"\\n\") {\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\treturn {\n\n\t\tbind() {\n\t\t\tgl.useProgram(id);\n\t\t},\n\n\t\tunbind() {\n\t\t\tgl.useProgram(null);\n\t\t},\n\n\t\tsend(uniform: Uniform) {\n\t\t\tthis.bind();\n\t\t\tfor (const name in uniform) {\n\t\t\t\tconst val = uniform[name];\n\t\t\t\tconst loc = gl.getUniformLocation(id, name);\n\t\t\t\tif (typeof val === \"number\") {\n\t\t\t\t\tgl.uniform1f(loc, val);\n\t\t\t\t} else if (val instanceof Mat4) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tgl.uniformMatrix4fv(loc, false, new Float32Array(val.m));\n\t\t\t\t} else if (val instanceof Color) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tgl.uniform4f(loc, val.r, val.g, val.b, val.a);\n\t\t\t\t} else if (val instanceof Vec3) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tgl.uniform3f(loc, val.x, val.y, val.z);\n\t\t\t\t} else if (val instanceof Vec2) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tgl.uniform2f(loc, val.x, val.y);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.unbind();\n\t\t},\n\n\t};\n\n}\n\nfunction makeFont(\n\ttex: GfxTexture,\n\tgw: number,\n\tgh: number,\n\tchars: string,\n): GfxFont {\n\n\tconst cols = tex.width / gw;\n\tconst rows = tex.height / gh;\n\tconst qw = 1.0 / cols;\n\tconst qh = 1.0 / rows;\n\tconst map: Record<string, Vec2> = {};\n\tconst charMap = chars.split(\"\").entries();\n\n\tfor (const [i, ch] of charMap) {\n\t\tmap[ch] = vec2(\n\t\t\t(i % cols) * qw,\n\t\t\tMath.floor(i / cols) * qh,\n\t\t);\n\t}\n\n\treturn {\n\t\ttex: tex,\n\t\tmap: map,\n\t\tqw: qw,\n\t\tqh: qh,\n\t};\n\n}\n\n// TODO: expose\nfunction drawRaw(\n\tverts: Vertex[],\n\tindices: number[],\n\tfixed: boolean,\n\ttex: GfxTexture = gfx.defTex,\n\tshader: GfxShader = gfx.defShader,\n\tuniform: Uniform = {},\n) {\n\n\ttex = tex ?? gfx.defTex;\n\tshader = shader ?? gfx.defShader;\n\n\t// flush on texture / shader change and overflow\n\tif (\n\t\ttex !== gfx.curTex\n\t\t|| shader !== gfx.curShader\n\t\t|| !deepEq(gfx.curUniform, uniform)\n\t\t|| gfx.vqueue.length + verts.length * STRIDE > QUEUE_COUNT\n\t\t|| gfx.iqueue.length + indices.length > QUEUE_COUNT\n\t) {\n\t\tflush();\n\t}\n\n\tfor (const v of verts) {\n\n\t\t// TODO: cache camTransform * gfxTransform?\n\t\tconst transform = fixed ? gfx.transform : game.cam.transform.mult(gfx.transform);\n\n\t\t// normalized world space coordinate [-1.0 ~ 1.0]\n\t\tconst pt = screen2ndc(transform.multVec2(v.pos.xy()));\n\n\t\tgfx.vqueue.push(\n\t\t\tpt.x, pt.y, v.pos.z,\n\t\t\tv.uv.x, v.uv.y,\n\t\t\tv.color.r / 255, v.color.g / 255, v.color.b / 255, v.opacity,\n\t\t);\n\n\t}\n\n\tfor (const i of indices) {\n\t\tgfx.iqueue.push(i + gfx.vqueue.length / STRIDE - verts.length);\n\t}\n\n\tgfx.curTex = tex;\n\tgfx.curShader = shader;\n\tgfx.curUniform = uniform;\n\n}\n\n// draw all batched shapes\nfunction flush() {\n\n\tif (\n\t\t!gfx.curTex\n\t\t|| !gfx.curShader\n\t\t|| gfx.vqueue.length === 0\n\t\t|| gfx.iqueue.length === 0\n\t) {\n\t\treturn;\n\t}\n\n\tconst gl = app.gl;\n\n\tgfx.curShader.send(gfx.curUniform);\n\tgl.bindBuffer(gl.ARRAY_BUFFER, gfx.vbuf);\n\tgl.bufferSubData(gl.ARRAY_BUFFER, 0, new Float32Array(gfx.vqueue));\n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gfx.ibuf);\n\tgl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, new Uint16Array(gfx.iqueue));\n\tgfx.curShader.bind();\n\tgfx.curTex.bind();\n\tgl.drawElements(gl.TRIANGLES, gfx.iqueue.length, gl.UNSIGNED_SHORT, 0);\n\tgfx.curTex.unbind();\n\tgfx.curShader.unbind();\n\tgl.bindBuffer(gl.ARRAY_BUFFER, null);\n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n\n\tgfx.iqueue = [];\n\tgfx.vqueue = [];\n\n\tgfx.drawCalls++;\n\n}\n\n// start a rendering frame, reset some states\nfunction frameStart() {\n\n\tapp.gl.clear(app.gl.COLOR_BUFFER_BIT);\n\n\tif (!gopt.background) {\n\t\tdrawUVQuad({\n\t\t\twidth: width(),\n\t\t\theight: height(),\n\t\t\tquad: new Quad(\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\twidth() * app.scale / BG_GRID_SIZE,\n\t\t\t\theight() * app.scale / BG_GRID_SIZE,\n\t\t\t),\n\t\t\ttex: gfx.bgTex,\n\t\t\tfixed: true,\n\t\t})\n\t}\n\n\tgfx.drawCalls = 0;\n\tgfx.transformStack = [];\n\tgfx.transform = new Mat4();\n\n}\n\nfunction frameEnd() {\n\tflush();\n\tgfx.lastDrawCalls = gfx.drawCalls;\n}\n\nfunction drawCalls() {\n\treturn gfx.lastDrawCalls;\n}\n\n// convert a screen space coordinate to webgl normalized device coordinate\nfunction screen2ndc(pt: Vec2): Vec2 {\n\treturn vec2(\n\t\tpt.x / width() * 2 - 1,\n\t\t-pt.y / height() * 2 + 1,\n\t);\n}\n\n// convert a webgl normalied device coordinate to screen space coordinate\nfunction ndc2screen(pt: Vec2): Vec2 {\n\treturn vec2(\n\t\t(pt.x + 1) / 2 * width(),\n\t\t-(pt.y - 1) / 2 * height(),\n\t);\n}\n\nfunction applyMatrix(m: Mat4) {\n\tgfx.transform = m.clone();\n}\n\nfunction pushTranslate(...args) {\n\tif (args[0] === undefined) return;\n\tconst p = vec2(...args);\n\tif (p.x === 0 && p.y === 0) return;\n\tgfx.transform = gfx.transform.translate(p);\n}\n\nfunction pushScale(...args) {\n\tif (args[0] === undefined) return;\n\tconst p = vec2(...args);\n\tif (p.x === 1 && p.y === 1) return;\n\tgfx.transform = gfx.transform.scale(p);\n}\n\nfunction pushRotateX(a: number) {\n\tif (!a) {\n\t\treturn;\n\t}\n\tgfx.transform = gfx.transform.rotateX(a);\n}\n\nfunction pushRotateY(a: number) {\n\tif (!a) {\n\t\treturn;\n\t}\n\tgfx.transform = gfx.transform.rotateY(a);\n}\n\nfunction pushRotateZ(a: number) {\n\tif (!a) {\n\t\treturn;\n\t}\n\tgfx.transform = gfx.transform.rotateZ(a);\n}\n\nfunction pushTransform() {\n\tgfx.transformStack.push(gfx.transform.clone());\n}\n\nfunction popTransform() {\n\tif (gfx.transformStack.length > 0) {\n\t\tgfx.transform = gfx.transformStack.pop();\n\t}\n}\n\n// draw a uv textured quad\nfunction drawUVQuad(opt: DrawUVQuadOpt) {\n\n\tif (opt.width === undefined || opt.height === undefined) {\n\t\tthrow new Error(\"drawUVQuad() requires property \\\"width\\\" and \\\"height\\\".\");\n\t}\n\n\tif (opt.width <= 0 || opt.height <= 0) {\n\t\treturn;\n\t}\n\n\tconst w = opt.width;\n\tconst h = opt.height;\n\tconst origin = originPt(opt.origin || DEF_ORIGIN);\n\tconst offset = origin.scale(vec2(w, h).scale(-0.5));\n\tconst q = opt.quad || new Quad(0, 0, 1, 1);\n\tconst color = opt.color || rgb(255, 255, 255);\n\tconst opacity = opt.opacity ?? 1;\n\n\tpushTransform();\n\tpushTranslate(opt.pos);\n\tpushRotateZ(opt.angle);\n\tpushScale(opt.scale);\n\tpushTranslate(offset);\n\n\tdrawRaw([\n\t\t{\n\t\t\tpos: vec3(-w / 2, h / 2, 0),\n\t\t\tuv: vec2(opt.flipX ? q.x + q.w : q.x, opt.flipY ? q.y : q.y + q.h),\n\t\t\tcolor: color,\n\t\t\topacity: opacity,\n\t\t},\n\t\t{\n\t\t\tpos: vec3(-w / 2, -h / 2, 0),\n\t\t\tuv: vec2(opt.flipX ? q.x + q.w : q.x, opt.flipY ? q.y + q.h : q.y),\n\t\t\tcolor: color,\n\t\t\topacity: opacity,\n\t\t},\n\t\t{\n\t\t\tpos: vec3(w / 2, -h / 2, 0),\n\t\t\tuv: vec2(opt.flipX ? q.x : q.x + q.w, opt.flipY ? q.y + q.h : q.y),\n\t\t\tcolor: color,\n\t\t\topacity: opacity,\n\t\t},\n\t\t{\n\t\t\tpos: vec3(w / 2, h / 2, 0),\n\t\t\tuv: vec2(opt.flipX ? q.x : q.x + q.w, opt.flipY ? q.y : q.y + q.h),\n\t\t\tcolor: color,\n\t\t\topacity: opacity,\n\t\t},\n\t], [0, 1, 3, 1, 2, 3], opt.fixed, opt.tex, opt.shader, opt.uniform);\n\n\tpopTransform();\n\n}\n\n// TODO: clean\nfunction drawTexture(opt: DrawTextureOpt) {\n\n\tif (!opt.tex) {\n\t\tthrow new Error(\"drawTexture() requires property \\\"tex\\\".\");\n\t}\n\n\tconst q = opt.quad ?? new Quad(0, 0, 1, 1);\n\tconst w = opt.tex.width * q.w;\n\tconst h = opt.tex.height * q.h;\n\tconst scale = vec2(1);\n\n\tif (opt.tiled) {\n\n\t\t// TODO: draw fract\n\t\tconst repX = Math.ceil((opt.width || w) / w);\n\t\tconst repY = Math.ceil((opt.height || h) / h);\n\t\tconst origin = originPt(opt.origin || DEF_ORIGIN).add(vec2(1, 1)).scale(0.5);\n\t\tconst offset = origin.scale(repX * w, repY * h);\n\n\t\t// TODO: rotation\n\t\tfor (let i = 0; i < repX; i++) {\n\t\t\tfor (let j = 0; j < repY; j++) {\n\t\t\t\tdrawUVQuad({\n\t\t\t\t\t...opt,\n\t\t\t\t\tpos: (opt.pos || vec2(0)).add(vec2(w * i, h * j)).sub(offset),\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tscale: scale.scale(opt.scale || vec2(1)),\n\t\t\t\t\ttex: opt.tex,\n\t\t\t\t\tquad: q,\n\t\t\t\t\twidth: w,\n\t\t\t\t\theight: h,\n\t\t\t\t\torigin: \"topleft\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else {\n\n\t\t// TODO: should this ignore scale?\n\t\tif (opt.width && opt.height) {\n\t\t\tscale.x = opt.width / w;\n\t\t\tscale.y = opt.height / h;\n\t\t} else if (opt.width) {\n\t\t\tscale.x = opt.width / w;\n\t\t\tscale.y = scale.x;\n\t\t} else if (opt.height) {\n\t\t\tscale.y = opt.height / h;\n\t\t\tscale.x = scale.y;\n\t\t}\n\n\t\tdrawUVQuad({\n\t\t\t...opt,\n\t\t\t// @ts-ignore\n\t\t\tscale: scale.scale(opt.scale || vec2(1)),\n\t\t\ttex: opt.tex,\n\t\t\tquad: q,\n\t\t\twidth: w,\n\t\t\theight: h,\n\t\t});\n\n\t}\n\n}\n\n// TODO: use native asset loader tracking\nconst loading = new Set();\n\nfunction drawSprite(opt: DrawSpriteOpt) {\n\n\tif (!opt.sprite) {\n\t\tthrow new Error(`drawSprite() requires property \"sprite\"`);\n\t}\n\n\tconst spr = findAsset(opt.sprite, assets.sprites);\n\n\tif (!spr) {\n\n\t\t// if passes a source url, we load it implicitly\n\t\tif (typeof opt.sprite === \"string\") {\n\t\t\tif (!loading.has(opt.sprite)) {\n\t\t\t\tloading.add(opt.sprite);\n\t\t\t\tloadSprite(opt.sprite, opt.sprite)\n\t\t\t\t\t.then((a) => loading.delete(opt.sprite));\n\t\t\t}\n\t\t\treturn;\n\t\t} else {\n\t\t\tthrow new Error(`sprite not found: \"${opt.sprite}\"`);\n\t\t}\n\n\t}\n\n\tconst q = spr.frames[opt.frame ?? 0];\n\n\tif (!q) {\n\t\tthrow new Error(`frame not found: ${opt.frame ?? 0}`);\n\t}\n\n\tdrawTexture({\n\t\t...opt,\n\t\ttex: spr.tex,\n\t\tquad: q.scale(opt.quad || new Quad(0, 0, 1, 1)),\n\t\tuniform: opt.uniform,\n\t});\n\n}\n\n// generate vertices to form an arc\nfunction getArcPts(\n\tpos: Vec2,\n\tradiusX: number,\n\tradiusY: number,\n\tstart: number,\n\tend: number,\n\tres: number = 1,\n): Vec2[] {\n\n\t// normalize and turn start and end angles to radians\n\tstart = deg2rad(start % 360);\n\tend = deg2rad(end % 360);\n\tif (end <= start) end += Math.PI * 2;\n\n\t// TODO: better way to get this?\n\t// the number of vertices is sqrt(r1 + r2) * 3 * res with a minimum of 16\n\tconst nverts = Math.ceil(Math.max(Math.sqrt(radiusX + radiusY) * 3 * (res || 1), 16));\n\tconst step = (end - start) / nverts;\n\tconst pts = [];\n\n\t// calculate vertices\n\tfor (let a = start; a < end; a += step) {\n\t\tpts.push(pos.add(radiusX * Math.cos(a), radiusY * Math.sin(a)));\n\t}\n\n\t// doing this on the side due to possible floating point inaccuracy\n\tpts.push(pos.add(radiusX * Math.cos(end), radiusY * Math.sin(end)));\n\n\treturn pts;\n\n}\n\nfunction drawRect(opt: DrawRectOpt) {\n\n\tif (opt.width === undefined || opt.height === undefined) {\n\t\tthrow new Error(\"drawRect() requires property \\\"width\\\" and \\\"height\\\".\");\n\t}\n\n\tif (opt.width <= 0 || opt.height <= 0) {\n\t\treturn;\n\t}\n\n\tconst w = opt.width;\n\tconst h = opt.height;\n\tconst origin = originPt(opt.origin || DEF_ORIGIN).add(1, 1);\n\tconst offset = origin.scale(vec2(w, h).scale(-0.5));\n\n\tlet pts = [\n\t\tvec2(0, 0),\n\t\tvec2(w, 0),\n\t\tvec2(w, h),\n\t\tvec2(0, h),\n\t];\n\n\t// TODO: drawPolygon should handle generic rounded corners\n\tif (opt.radius) {\n\n\t\t// maxium radius is half the shortest side\n\t\tconst r = Math.min(Math.min(w, h) / 2, opt.radius);\n\n\t\tpts = [\n\t\t\tvec2(r, 0),\n\t\t\tvec2(w - r, 0),\n\t\t\t...getArcPts(vec2(w - r, r), r, r, 270, 360),\n\t\t\tvec2(w, r),\n\t\t\tvec2(w, h - r),\n\t\t\t...getArcPts(vec2(w - r, h - r), r, r, 0, 90),\n\t\t\tvec2(w - r, h),\n\t\t\tvec2(r, h),\n\t\t\t...getArcPts(vec2(r, h - r), r, r, 90, 180),\n\t\t\tvec2(0, h - r),\n\t\t\tvec2(0, r),\n\t\t\t...getArcPts(vec2(r, r), r, r, 180, 270),\n\t\t];\n\n\t}\n\n\tdrawPolygon({ ...opt, offset, pts });\n\n}\n\nfunction drawLine(opt: DrawLineOpt) {\n\n\tconst { p1, p2 } = opt;\n\n\tif (!p1 || !p2) {\n\t\tthrow new Error(\"drawLine() requires properties \\\"p1\\\" and \\\"p2\\\".\");\n\t}\n\n\tconst w = opt.width || 1;\n\n\t// the displacement from the line end point to the corner point\n\tconst dis = p2.sub(p1).unit().normal().scale(w * 0.5);\n\n\t// calculate the 4 corner points of the line polygon\n\tconst verts = [\n\t\tp1.sub(dis),\n\t\tp1.add(dis),\n\t\tp2.add(dis),\n\t\tp2.sub(dis),\n\t].map((p) => ({\n\t\tpos: vec3(p.x, p.y, 0),\n\t\tuv: vec2(0),\n\t\tcolor: opt.color ?? Color.WHITE,\n\t\topacity: opt.opacity ?? 1,\n\t}));\n\n\tdrawRaw(verts, [0, 1, 3, 1, 2, 3], opt.fixed, gfx.defTex, opt.shader, opt.uniform);\n\n}\n\nfunction drawLines(opt: DrawLinesOpt) {\n\n\tconst pts = opt.pts;\n\n\tif (!pts) {\n\t\tthrow new Error(\"drawLines() requires property \\\"pts\\\".\");\n\t}\n\n\tif (pts.length < 2) {\n\t\treturn;\n\t}\n\n\tif (opt.radius && pts.length >= 3) {\n\n\t\t// TODO: rounded vertices for arbitury polygonic shape\n\t\tlet minLen = pts[0].dist(pts[1]);\n\n\t\tfor (let i = 1; i < pts.length - 1; i++) {\n\t\t\tminLen = Math.min(pts[i].dist(pts[i + 1]), minLen);\n\t\t}\n\n\t\tconst radius = Math.min(opt.radius, minLen / 2);\n\n\t\tdrawLine({ ...opt, p1: pts[0], p2: pts[1], });\n\n\t\tfor (let i = 1; i < pts.length - 2; i++) {\n\t\t\tconst p1 = pts[i];\n\t\t\tconst p2 = pts[i + 1];\n\t\t\tdrawLine({\n\t\t\t\t...opt,\n\t\t\t\tp1: p1,\n\t\t\t\tp2: p2,\n\t\t\t});\n\t\t}\n\n\t\tdrawLine({ ...opt, p1: pts[pts.length - 2], p2: pts[pts.length - 1], });\n\n\t} else {\n\n\t\tfor (let i = 0; i < pts.length - 1; i++) {\n\t\t\tdrawLine({\n\t\t\t\t...opt,\n\t\t\t\tp1: pts[i],\n\t\t\t\tp2: pts[i + 1],\n\t\t\t});\n\t\t}\n\n\t}\n\n}\n\nfunction drawTriangle(opt: DrawTriangleOpt) {\n\tif (!opt.p1 || !opt.p2 || !opt.p3) {\n\t\tthrow new Error(\"drawPolygon() requires properties \\\"p1\\\", \\\"p2\\\" and \\\"p3\\\".\");\n\t}\n\treturn drawPolygon({\n\t\t...opt,\n\t\tpts: [opt.p1, opt.p2, opt.p3],\n\t});\n}\n\n// TODO: origin\nfunction drawCircle(opt: DrawCircleOpt) {\n\n\tif (!opt.radius) {\n\t\tthrow new Error(\"drawCircle() requires property \\\"radius\\\".\");\n\t}\n\n\tif (opt.radius === 0) {\n\t\treturn;\n\t}\n\n\tdrawEllipse({\n\t\t...opt,\n\t\tradiusX: opt.radius,\n\t\tradiusY: opt.radius,\n\t\tangle: 0,\n\t});\n\n}\n\n// TODO: use fan-like triangulation\nfunction drawEllipse(opt: DrawEllipseOpt) {\n\n\tif (opt.radiusX === undefined || opt.radiusY === undefined) {\n\t\tthrow new Error(\"drawEllipse() requires properties \\\"radiusX\\\" and \\\"radiusY\\\".\");\n\t}\n\n\tif (opt.radiusX === 0 || opt.radiusY === 0) {\n\t\treturn;\n\t}\n\n\tdrawPolygon({\n\t\t...opt,\n\t\tpts: getArcPts(\n\t\t\tvec2(0),\n\t\t\topt.radiusX,\n\t\t\topt.radiusY,\n\t\t\topt.start ?? 0,\n\t\t\topt.end ?? 360,\n\t\t\topt.resolution\n\t\t),\n\t\tradius: 0,\n\t});\n\n}\n\nfunction drawPolygon(opt: DrawPolygonOpt) {\n\n\tif (!opt.pts) {\n\t\tthrow new Error(\"drawPolygon() requires property \\\"pts\\\".\");\n\t}\n\n\tconst npts = opt.pts.length;\n\n\tif (npts < 3) {\n\t\treturn;\n\t}\n\n\tpushTransform();\n\tpushTranslate(opt.pos);\n\tpushScale(opt.scale);\n\tpushRotateZ(opt.angle);\n\tpushTranslate(opt.offset);\n\n\tif (opt.fill !== false) {\n\n\t\tconst color = opt.color ?? Color.WHITE;\n\n\t\tconst verts = opt.pts.map((pt) => ({\n\t\t\tpos: vec3(pt.x, pt.y, 0),\n\t\t\tuv: vec2(0, 0),\n\t\t\tcolor: color,\n\t\t\topacity: opt.opacity ?? 1,\n\t\t}));\n\n\t\t// TODO: better triangulation\n\t\tconst indices = [...Array(npts - 2).keys()]\n\t\t\t.map((n) => [0, n + 1, n + 2])\n\t\t\t.flat();\n\n\t\tdrawRaw(verts, opt.indices ?? indices, opt.fixed, gfx.defTex, opt.shader, opt.uniform);\n\n\t}\n\n\tif (opt.outline) {\n\t\tdrawLines({\n\t\t\tpts: [ ...opt.pts, opt.pts[0] ],\n\t\t\tradius: opt.radius,\n\t\t\twidth: opt.outline.width,\n\t\t\tcolor: opt.outline.color,\n\t\t\tuniform: opt.uniform,\n\t\t\tfixed: opt.fixed,\n\t\t});\n\t}\n\n\tpopTransform();\n\n}\n\nfunction applyCharTransform(fchar: FormattedChar, tr: CharTransform) {\n\tif (tr.pos) fchar.pos = fchar.pos.add(tr.pos);\n\tif (tr.scale) fchar.scale = fchar.scale.scale(vec2(tr.scale));\n\tif (tr.angle) fchar.angle += tr.angle;\n\tif (tr.color) fchar.color = fchar.color.mult(tr.color);\n\tif (tr.opacity) fchar.opacity *= tr.opacity;\n}\n\n// TODO: escape\nconst TEXT_STYLE_RE = /\\[(?<text>[^\\]]*)\\]\\.(?<style>[\\w\\.]+)+/g;\n\nfunction compileStyledText(text: string): {\n\tcharStyleMap: Record<number, {\n\t\tlocalIdx: number,\n\t\tstyles: string[],\n\t}>,\n\ttext: string,\n} {\n\n\tconst charStyleMap = {};\n\t// get the text without the styling syntax\n\tconst renderText = text.replace(TEXT_STYLE_RE, \"$1\");\n\tlet idxOffset = 0;\n\n\t// put each styled char index into a map for easy access when iterating each char\n\tfor (const match of text.matchAll(TEXT_STYLE_RE)) {\n\t\tconst styles = match.groups.style.split(\".\");\n\t\tconst origIdx = match.index - idxOffset;\n\t\tfor (\n\t\t\tlet i = origIdx;\n\t\t\ti < match.index + match.groups.text.length;\n\t\t\ti++\n\t\t) {\n\t\t\tcharStyleMap[i] = {\n\t\t\t\tlocalIdx: i - origIdx,\n\t\t\t\tstyles: styles,\n\t\t\t};\n\t\t}\n\t\t// omit \"[\", \"]\", \".\" and the style text in the format string when calculating index\n\t\tidxOffset += 3 + match.groups.style.length;\n\t}\n\n\treturn {\n\t\tcharStyleMap: charStyleMap,\n\t\ttext: renderText,\n\t};\n\n}\n\nfunction findAsset<T>(src: string | T, lib: Record<string, T>, def?: string): T | undefined {\n\tif (src) {\n\t\treturn typeof src === \"string\" ? lib[src] : src;\n\t} else if (def) {\n\t\treturn lib[def];\n\t}\n}\n\n// format text and return a list of chars with their calculated position\nfunction formatText(opt: DrawTextOpt): FormattedText {\n\n\tif (opt.text === undefined) {\n\t\tthrow new Error(\"formatText() requires property \\\"text\\\".\");\n\t}\n\n\tconst font = findAsset(opt.font ?? gopt.font, assets.fonts, DEF_FONT);\n\n\tif (!font) {\n\t\tthrow new Error(`Font not found: ${opt.font}`);\n\t}\n\n\tconst { charStyleMap, text } = compileStyledText(opt.text + \"\");\n\tconst chars = text.split(\"\");\n\tconst gw = font.qw * font.tex.width;\n\tconst gh = font.qh * font.tex.height;\n\tconst size = opt.size || gh;\n\tconst scale = vec2(size / gh).scale(vec2(opt.scale || 1));\n\tconst cw = scale.x * gw + (opt.letterSpacing ?? 0);\n\tconst ch = scale.y * gh + (opt.lineSpacing ?? 0);\n\tlet curX = 0;\n\tlet th = ch;\n\tlet tw = 0;\n\tconst flines = [];\n\tlet curLine = [];\n\tlet lastSpace = null;\n\tlet cursor = 0;\n\n\twhile (cursor < chars.length) {\n\n\t\tlet char = chars[cursor];\n\n\t\t// check new line\n\t\tif (char === \"\\n\") {\n\t\t\t// always new line on '\\n'\n\t\t\tth += ch;\n\t\t\tcurX = 0;\n\t\t\tlastSpace = null;\n\t\t\tcurLine.push(char);\n\t\t\tflines.push(curLine);\n\t\t\tcurLine = [];\n\t\t} else if ((opt.width ? (curX + cw > opt.width) : false)) {\n\t\t\t// new line on last word if width exceeds\n\t\t\tth += ch;\n\t\t\tcurX = 0;\n\t\t\tif (lastSpace != null) {\n\t\t\t\tcursor -= curLine.length - lastSpace;\n\t\t\t\tchar = chars[cursor];\n\t\t\t\tcurLine = curLine.slice(0, lastSpace);\n\t\t\t}\n\t\t\tlastSpace = null;\n\t\t\tflines.push(curLine);\n\t\t\tcurLine = [];\n\t\t}\n\n\t\t// push char\n\t\tif (char !== \"\\n\") {\n\t\t\tcurLine.push(char);\n\t\t\tcurX += cw;\n\t\t\tif (char === \" \") {\n\t\t\t\tlastSpace = curLine.length;\n\t\t\t}\n\t\t}\n\n\t\ttw = Math.max(tw, curX);\n\t\tcursor++;\n\n\t}\n\n\tflines.push(curLine);\n\n\tif (opt.width) {\n\t\ttw = opt.width;\n\t}\n\n\t// whole text offset\n\tconst fchars = [];\n\tconst pos = vec2(opt.pos || 0);\n\tconst offset = originPt(opt.origin || DEF_ORIGIN).scale(0.5);\n\t// this math is complicated i forgot how it works instantly\n\tconst ox = -offset.x * cw - (offset.x + 0.5) * (tw - cw);\n\tconst oy = -offset.y * ch - (offset.y + 0.5) * (th - ch);\n\tlet idx = 0;\n\n\tflines.forEach((line, ln) => {\n\n\t\t// line offset\n\t\tconst oxl = (tw - line.length * cw) * (offset.x + 0.5);\n\n\t\tline.forEach((char, cn) => {\n\t\t\tconst qpos = font.map[char];\n\t\t\tconst x = cn * cw;\n\t\t\tconst y = ln * ch;\n\t\t\tif (qpos) {\n\t\t\t\tconst fchar: FormattedChar = {\n\t\t\t\t\ttex: font.tex,\n\t\t\t\t\tquad: new Quad(qpos.x, qpos.y, font.qw, font.qh),\n\t\t\t\t\tch: char,\n\t\t\t\t\tpos: vec2(pos.x + x + ox + oxl, pos.y + y + oy),\n\t\t\t\t\topacity: opt.opacity,\n\t\t\t\t\tcolor: opt.color ?? rgb(255, 255, 255),\n\t\t\t\t\tscale: scale,\n\t\t\t\t\tangle: 0,\n\t\t\t\t\tuniform: opt.uniform,\n\t\t\t\t\tfixed: opt.fixed,\n\t\t\t\t}\n\t\t\t\tif (opt.transform) {\n\t\t\t\t\tconst tr = typeof opt.transform === \"function\"\n\t\t\t\t\t\t? opt.transform(idx, char)\n\t\t\t\t\t\t: opt.transform;\n\t\t\t\t\tif (tr) {\n\t\t\t\t\t\tapplyCharTransform(fchar, tr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (charStyleMap[idx]) {\n\t\t\t\t\tconst { styles, localIdx } = charStyleMap[idx];\n\t\t\t\t\tfor (const name of styles) {\n\t\t\t\t\t\tconst style = opt.styles[name];\n\t\t\t\t\t\tconst tr = typeof style === \"function\"\n\t\t\t\t\t\t\t? style(localIdx, char)\n\t\t\t\t\t\t\t: style;\n\t\t\t\t\t\tif (tr) {\n\t\t\t\t\t\t\tapplyCharTransform(fchar, tr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfchars.push(fchar);\n\t\t\t}\n\t\t\tidx += 1;\n\t\t});\n\t});\n\n\treturn {\n\t\twidth: tw,\n\t\theight: th,\n\t\tchars: fchars,\n\t};\n\n}\n\nfunction drawText(opt: DrawTextOpt) {\n\tdrawFormattedText(formatText(opt));\n}\n\n// TODO: rotation\nfunction drawFormattedText(ftext: FormattedText) {\n\tfor (const ch of ftext.chars) {\n\t\tdrawUVQuad({\n\t\t\ttex: ch.tex,\n\t\t\twidth: ch.tex.width * ch.quad.w,\n\t\t\theight: ch.tex.height * ch.quad.h,\n\t\t\tpos: ch.pos,\n\t\t\tscale: ch.scale,\n\t\t\tangle: ch.angle,\n\t\t\tcolor: ch.color,\n\t\t\topacity: ch.opacity,\n\t\t\tquad: ch.quad,\n\t\t\t// TODO: topleft\n\t\t\torigin: \"center\",\n\t\t\tuniform: ch.uniform,\n\t\t\tfixed: ch.fixed,\n\t\t});\n\t}\n}\n\n/**\n * Update viewport based on user setting and fullscreen state\n */\nfunction updateViewport() {\n\n\tconst gl = app.gl;\n\n\t// canvas size\n\tconst cw = gl.drawingBufferWidth;\n\tconst ch = gl.drawingBufferHeight;\n\n\t// game size\n\tconst gw = width();\n\tconst gh = height();\n\n\tif (isFullscreen()) {\n\t\t// TODO: doesn't work with letterbox\n\t\tconst ww = window.innerWidth;\n\t\tconst wh = window.innerHeight;\n\t\tconst rw = ww / wh;\n\t\tconst rc = cw / ch;\n\t\tif (rw > rc) {\n\t\t\tconst sw = window.innerHeight * rc;\n\t\t\tgfx.viewport = {\n\t\t\t\tx: (ww - sw) / 2,\n\t\t\t\ty: 0,\n\t\t\t\twidth: sw,\n\t\t\t\theight: wh,\n\t\t\t};\n\t\t} else {\n\t\t\tconst sh = window.innerWidth / rc;\n\t\t\tgfx.viewport = {\n\t\t\t\tx: 0,\n\t\t\t\ty: (wh - sh) / 2,\n\t\t\t\twidth: ww,\n\t\t\t\theight: sh,\n\t\t\t};\n\t\t}\n\t\treturn;\n\t}\n\n\tif (gopt.letterbox) {\n\n\t\tif (!gopt.width || !gopt.height) {\n\t\t\tthrow new Error(\"Letterboxing requires width and height defined.\");\n\t\t}\n\n\t\tconst rc = cw / ch;\n\t\tconst rg = gopt.width / gopt.height;\n\n\t\tif (rc > rg) {\n\t\t\tif (!gopt.stretch) {\n\t\t\t\tgfx.width = ch * rg;\n\t\t\t\tgfx.height = ch;\n\t\t\t}\n\t\t\tconst sw = ch * rg;\n\t\t\tconst sh = ch;\n\t\t\tconst x = (cw - sw) / 2;\n\t\t\tgl.scissor(x, 0, sw, sh);\n\t\t\tgl.viewport(x, 0, sw, ch);\n\t\t\tgfx.viewport = {\n\t\t\t\tx: x,\n\t\t\t\ty: 0,\n\t\t\t\twidth: sw,\n\t\t\t\theight: ch,\n\t\t\t};\n\t\t} else {\n\t\t\tif (!gopt.stretch) {\n\t\t\t\tgfx.width = cw;\n\t\t\t\tgfx.height = cw / rg;\n\t\t\t}\n\t\t\tconst sw = cw;\n\t\t\tconst sh = cw / rg;\n\t\t\tconst y = (ch - sh) / 2;\n\t\t\tgl.scissor(0, y, sw, sh);\n\t\t\tgl.viewport(0, y, cw, sh);\n\t\t\tgfx.viewport = {\n\t\t\t\tx: 0,\n\t\t\t\ty: y,\n\t\t\t\twidth: cw,\n\t\t\t\theight: sh,\n\t\t\t};\n\t\t}\n\n\t\treturn;\n\n\t}\n\n\tif (gopt.stretch) {\n\n\t\tif (!gopt.width || !gopt.height) {\n\t\t\tthrow new Error(\"Stretching requires width and height defined.\");\n\t\t}\n\n\t\tgl.viewport(0, 0, cw, ch);\n\n\t\tgfx.viewport = {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth: cw,\n\t\t\theight: ch,\n\t\t};\n\n\t\treturn;\n\t}\n\n\tgfx.width = cw / app.scale;\n\tgfx.height = ch / app.scale;\n\tgl.viewport(0, 0, cw, ch);\n\n\tgfx.viewport = {\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth: cw,\n\t\theight: ch,\n\t};\n\n}\n\n// get game width\nfunction width(): number {\n\treturn gfx.width;\n}\n\n// get game height\nfunction height(): number {\n\treturn gfx.height;\n}\n\n// TODO: support remove events\napp.canvas.addEventListener(\"mousemove\", (e) => {\n\tapp.mousePos = vec2(\n\t\t(e.offsetX - gfx.viewport.x) * width() / gfx.viewport.width,\n\t\t(e.offsetY - gfx.viewport.y) * height() / gfx.viewport.height,\n\t);\n\tapp.mouseDeltaPos = vec2(e.movementX, e.movementY).scale(1 / app.scale);\n\tapp.isMouseMoved = true;\n});\n\napp.canvas.addEventListener(\"mousedown\", (e) => {\n\tconst m = MOUSE_BUTTONS[e.button];\n\tif (m) {\n\t\tapp.mouseStates[m] = \"pressed\";\n\t}\n});\n\napp.canvas.addEventListener(\"mouseup\", (e) => {\n\tconst m = MOUSE_BUTTONS[e.button];\n\tif (m) {\n\t\tapp.mouseStates[m] = \"released\";\n\t}\n});\n\napp.canvas.addEventListener(\"keydown\", (e) => {\n\n\tconst k = KEY_ALIAS[e.key] || e.key.toLowerCase();\n\n\tif (PREVENT_DEFAULT_KEYS.includes(k)) {\n\t\te.preventDefault();\n\t}\n\n\tif (k.length === 1) {\n\t\tapp.charInputted.push(e.key);\n\t}\n\n\tif (k === \"space\") {\n\t\tapp.charInputted.push(\" \");\n\t}\n\n\tif (e.repeat) {\n\t\tapp.isKeyPressedRepeat = true;\n\t\tapp.keyStates[k] = \"rpressed\";\n\t} else {\n\t\tapp.isKeyPressed = true;\n\t\tapp.keyStates[k] = \"pressed\";\n\t}\n\n});\n\napp.canvas.addEventListener(\"keyup\", (e: KeyboardEvent) => {\n\tconst k = KEY_ALIAS[e.key] || e.key.toLowerCase();\n\tapp.keyStates[k] = \"released\";\n\tapp.isKeyReleased = true;\n});\n\napp.canvas.addEventListener(\"touchstart\", (e) => {\n\tif (!gopt.touchToMouse) return;\n\t// disable long tap context menu\n\te.preventDefault();\n\tconst t = e.touches[0];\n\tapp.mousePos = vec2(t.clientX, t.clientY).scale(1 / app.scale);\n\tapp.mouseStates[\"left\"] = \"pressed\";\n});\n\napp.canvas.addEventListener(\"touchmove\", (e) => {\n\tif (!gopt.touchToMouse) return;\n\t// disable scrolling\n\te.preventDefault();\n\tconst t = e.touches[0];\n\tapp.mousePos = vec2(t.clientX, t.clientY).scale(1 / app.scale);\n\tapp.isMouseMoved = true;\n});\n\napp.canvas.addEventListener(\"touchend\", (e) => {\n\tif (!gopt.touchToMouse) return;\n\tapp.mouseStates[\"left\"] = \"released\";\n});\n\napp.canvas.addEventListener(\"touchcancel\", (e) => {\n\tif (!gopt.touchToMouse) return;\n\tapp.mouseStates[\"left\"] = \"released\";\n});\n\napp.canvas.addEventListener(\"touchstart\", (e) => {\n\t[...e.changedTouches].forEach((t) => {\n\t\tgame.trigger(\"onTouchStart\", t.identifier, vec2(t.clientX, t.clientY).scale(1 / app.scale));\n\t});\n});\n\napp.canvas.addEventListener(\"touchmove\", (e) => {\n\t[...e.changedTouches].forEach((t) => {\n\t\tgame.trigger(\"onTouchMove\", t.identifier, vec2(t.clientX, t.clientY).scale(1 / app.scale));\n\t});\n});\n\napp.canvas.addEventListener(\"touchend\", (e) => {\n\t[...e.changedTouches].forEach((t) => {\n\t\tgame.trigger(\"onTouchEnd\", t.identifier, vec2(t.clientX, t.clientY).scale(1 / app.scale));\n\t});\n});\n\napp.canvas.addEventListener(\"contextmenu\", function (e) {\n\te.preventDefault();\n});\n\ndocument.addEventListener(\"visibilitychange\", () => {\n\tswitch (document.visibilityState) {\n\t\tcase \"visible\":\n\t\t\t// prevent a surge of dt() when switch back after the tab being hidden for a while\n\t\t\tapp.skipTime = true;\n\t\t\t// TODO: don't resume if debug.paused\n\t\t\taudio.ctx.resume();\n\t\t\tbreak;\n\t\tcase \"hidden\":\n\t\t\taudio.ctx.suspend();\n\t\t\tbreak;\n\t}\n});\n\n// TODO: not quite working\n// window.addEventListener(\"resize\", () => {\n// \tif (!(gopt.width && gopt.height && !gopt.stretch)) {\n// \t\tapp.canvas.width = app.canvas.parentElement.offsetWidth;\n// \t\tapp.canvas.height = app.canvas.parentElement.offsetHeight;\n// \t}\n// });\n\nfunction mousePos(): Vec2 {\n\treturn app.mousePos.clone();\n}\n\nfunction mouseDeltaPos(): Vec2 {\n\treturn app.mouseDeltaPos.clone();\n}\n\nfunction isMousePressed(m = \"left\"): boolean {\n\treturn app.mouseStates[m] === \"pressed\";\n}\n\nfunction isMouseDown(m = \"left\"): boolean {\n\treturn app.mouseStates[m] === \"pressed\" || app.mouseStates[m] === \"down\";\n}\n\nfunction isMouseReleased(m = \"left\"): boolean {\n\treturn app.mouseStates[m] === \"released\";\n}\n\nfunction isMouseMoved(): boolean {\n\treturn app.isMouseMoved;\n}\n\nfunction isKeyPressed(k?: string): boolean {\n\tif (k === undefined) {\n\t\treturn app.isKeyPressed;\n\t} else {\n\t\treturn app.keyStates[k] === \"pressed\";\n\t}\n}\n\nfunction isKeyPressedRepeat(k: string): boolean {\n\tif (k === undefined) {\n\t\treturn app.isKeyPressedRepeat;\n\t} else {\n\t\treturn app.keyStates[k] === \"pressed\" || app.keyStates[k] === \"rpressed\";\n\t}\n}\n\nfunction isKeyDown(k: string): boolean {\n\treturn app.keyStates[k] === \"pressed\"\n\t\t|| app.keyStates[k] === \"rpressed\"\n\t\t|| app.keyStates[k] === \"down\";\n}\n\nfunction isKeyReleased(k?: string): boolean {\n\tif (k === undefined) {\n\t\treturn app.isKeyReleased;\n\t} else {\n\t\treturn app.keyStates[k] === \"released\";\n\t}\n}\n\nfunction charInputted(): string[] {\n\treturn [...app.charInputted];\n}\n\nfunction time(): number {\n\treturn app.time;\n}\n\n// get a base64 png image of canvas\nfunction screenshot(): string {\n\treturn app.canvas.toDataURL();\n}\n\n// TODO: custom cursor\nfunction cursor(c?: Cursor): Cursor {\n\tif (c) {\n\t\tapp.canvas.style.cursor = c;\n\t}\n\treturn app.canvas.style.cursor;\n}\n\nfunction fullscreen(f: boolean = true) {\n\tif (f) {\n\t\tenterFullscreen(app.canvas);\n\t} else {\n\t\texitFullscreen();\n\t}\n}\n\nfunction isFullscreen(): boolean {\n\treturn Boolean(getFullscreenElement());\n}\n\nfunction quit() {\n\tcancelAnimationFrame(app.loopID);\n\tapp.stopped = true;\n}\n\nconst debug: Debug = {\n\tinspect: false,\n\ttimeScale: 1,\n\tshowLog: true,\n\tfps: () => app.fpsCounter.fps,\n\tobjCount(): number {\n\t\t// TODO: recursive count\n\t\treturn game.root.children.length;\n\t},\n\tstepFrame: updateFrame,\n\tdrawCalls: () => gfx.drawCalls,\n\tclearLog: () => game.logs = [],\n\tlog: (msg) => game.logs.unshift(`[${time().toFixed(2)}].time [${msg}].info`),\n\terror: (msg) => game.logs.unshift(`[${time().toFixed(2)}].time [${msg}].error`),\n\tcurRecording: null,\n\tget paused() {\n\t\treturn app.paused;\n\t},\n\tset paused(v) {\n\t\tapp.paused = v;\n\t\tif (v) {\n\t\t\taudio.ctx.suspend();\n\t\t} else {\n\t\t\taudio.ctx.resume();\n\t\t}\n\t}\n};\n\nfunction dt() {\n\treturn app.dt * debug.timeScale;\n}\n\nfunction mouseWorldPos(): Vec2 {\n\tdeprecateMsg(\"mouseWorldPos()\", \"toWorld(mousePos())\");\n\treturn toWorld(mousePos());\n}\n\ntype Camera = {\n\tpos: Vec2,\n\tscale: Vec2,\n\tangle: number,\n\tshake: number,\n};\n\ntype Layer = {\n\torder: number,\n}\n\ntype TaggedEvent = {\n\ttag: string,\n\tcb: (...args) => void,\n};\n\ntype KeyEvent = {\n\tkey: string,\n\tcb(),\n};\n\ntype MouseInputEvent = {\n\tcb(),\n};\n\ntype LoadEvent = () => void;\ntype NextFrameEvent = () => void;\ntype MouseEvent = () => void;\ntype CharEvent = (ch: string) => void;\n\nfunction layers(list: string[], def?: string) {\n\n\tlist.forEach((name, idx) => {\n\t\tgame.layers[name] = idx + 1;\n\t});\n\n\tif (def) {\n\t\tgame.defLayer = def;\n\t}\n\n}\n\nfunction camPos(...pos): Vec2 {\n\tif (pos.length > 0) {\n\t\tgame.cam.pos = vec2(...pos);\n\t}\n\treturn game.cam.pos.clone();\n}\n\nfunction camScale(...scale): Vec2 {\n\tif (scale.length > 0) {\n\t\tgame.cam.scale = vec2(...scale);\n\t}\n\treturn game.cam.scale.clone();\n}\n\nfunction camRot(angle: number): number {\n\tif (angle !== undefined) {\n\t\tgame.cam.angle = angle;\n\t}\n\treturn game.cam.angle;\n}\n\nfunction shake(intensity: number = 12) {\n\tgame.cam.shake = intensity;\n}\n\nfunction toScreen(p: Vec2): Vec2 {\n\treturn game.cam.transform.multVec2(p);\n}\n\nfunction toWorld(p: Vec2): Vec2 {\n\treturn game.cam.transform.invert().multVec2(p);\n}\n\nfunction make<T>(comps: CompList<T>): GameObj<T> {\n\n\tconst compStates = new Map();\n\tconst customState = {};\n\tlet events = {};\n\n\tconst obj = {\n\n\t\t_id: uid(),\n\t\thidden: false,\n\t\tpaused: false,\n\t\tchildren: [],\n\t\tparent: null,\n\n\t\t// TODO: accept gameobj\n\t\tadd<T2>(comps: CompList<T2>): GameObj<T2> {\n\t\t\tif (this !== game.root) {\n\t\t\t\tthrow new Error(\"Children game object not supported yet\");\n\t\t\t}\n\t\t\tconst obj = make(comps);\n\t\t\tobj.parent = this;\n\t\t\tobj.trigger(\"add\");\n\t\t\tonLoad(() => obj.trigger(\"load\"));\n\t\t\tthis.children.push(obj);\n\t\t\treturn obj;\n\t\t},\n\n\t\t// TODO: use add()\n\t\treadd(obj: GameObj): GameObj {\n\t\t\tthis.remove(obj);\n\t\t\tthis.children.push(obj);\n\t\t\treturn obj;\n\t\t},\n\n\t\tremove(obj: GameObj): void {\n\t\t\tconst idx = this.children.indexOf(obj);\n\t\t\tif (idx !== -1) {\n\t\t\t\tobj.parent = null;\n\t\t\t\tobj.trigger(\"destroy\");\n\t\t\t\tthis.children.splice(idx, 1);\n\t\t\t}\n\t\t},\n\n\t\tremoveAll(tag: Tag) {\n\t\t\tthis.every(tag, (obj) => this.remove(obj));\n\t\t},\n\n\t\tupdate() {\n\t\t\tif (this.paused) return;\n\t\t\tthis.revery((child) => child.update());\n\t\t\tthis.trigger(\"update\");\n\t\t},\n\n\t\tdraw() {\n\t\t\tif (this.hidden) return;\n\t\t\tpushTransform();\n\t\t\tpushTranslate(this.pos);\n\t\t\tpushScale(this.scale);\n\t\t\tpushRotateZ(this.angle);\n\t\t\tthis.every((child) => child.draw());\n\t\t\tthis.trigger(\"draw\");\n\t\t\tpopTransform();\n\t\t},\n\n\t\t// use a comp, or tag\n\t\tuse(comp: Comp | Tag) {\n\n\t\t\tif (!comp) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// tag\n\t\t\tif (typeof comp === \"string\") {\n\t\t\t\treturn this.use({\n\t\t\t\t\tid: comp\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// clear if overwrite\n\t\t\tif (comp.id) {\n\t\t\t\tthis.unuse(comp.id);\n\t\t\t\tcompStates.set(comp.id, {});\n\t\t\t}\n\n\t\t\t// state source location\n\t\t\tconst state = comp.id ? compStates.get(comp.id) : customState;\n\n\t\t\tstate.cleanups = [];\n\n\t\t\tfor (const k in comp) {\n\n\t\t\t\tif (COMP_DESC.has(k)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// event / custom method\n\t\t\t\tif (typeof comp[k] === \"function\") {\n\t\t\t\t\tconst func = comp[k].bind(this);\n\t\t\t\t\tif (COMP_EVENTS.has(k)) {\n\t\t\t\t\t\tstate.cleanups.push(this.on(k, func));\n\t\t\t\t\t\tstate[k] = func;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate[k] = func;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tstate[k] = comp[k];\n\t\t\t\t}\n\n\t\t\t\tif (this[k] === undefined) {\n\t\t\t\t\t// assign comp fields to game obj\n\t\t\t\t\tObject.defineProperty(this, k, {\n\t\t\t\t\t\tget: () => state[k],\n\t\t\t\t\t\tset: (val) => state[k] = val,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst checkDeps = () => {\n\t\t\t\tif (!comp.require) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const dep of comp.require) {\n\t\t\t\t\tif (!this.c(dep)) {\n\t\t\t\t\t\tthrow new Error(`comp '${comp.id}' requires comp '${dep}'`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// check deps or run add event\n\t\t\tif (this.exists()) {\n\t\t\t\tif (comp.add) {\n\t\t\t\t\tcomp.add.call(this);\n\t\t\t\t}\n\t\t\t\tif (comp.load) {\n\t\t\t\t\tonLoad(() => comp.load.call(this));\n\t\t\t\t}\n\t\t\t\tcheckDeps();\n\t\t\t} else {\n\t\t\t\tif (comp.require) {\n\t\t\t\t\tstate.cleanups.push(this.on(\"add\", checkDeps));\n\t\t\t\t}\n\t\t\t}\n\n\t\t},\n\n\t\tunuse(id: Tag) {\n\t\t\tif (compStates.has(id)) {\n\t\t\t\tconst comp = compStates.get(id);\n\t\t\t\tcomp.cleanups.forEach((f) => f());\n\t\t\t\tfor (const k in comp) {\n\t\t\t\t\tdelete comp[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tcompStates.delete(id);\n\t\t},\n\n\t\tc(id: Tag): Comp {\n\t\t\treturn compStates.get(id);\n\t\t},\n\n\t\t// TODO: a recursive variant\n\t\tget(t?: Tag | Tag[]): GameObj[] {\n\t\t\treturn this.children\n\t\t\t\t.filter((child) => t ? child.is(t) : true)\n\t\t\t\t.sort((o1, o2) => {\n\t\t\t\t\t// TODO: layers are deprecated\n\t\t\t\t\tconst l1 = game.layers[o1.layer ?? game.defLayer] ?? 0;\n\t\t\t\t\tconst l2 = game.layers[o2.layer ?? game.defLayer] ?? 0;\n\t\t\t\t\t// if on same layer, use \"z\" comp to decide which is on top, if given\n\t\t\t\t\tif (l1 == l2) {\n\t\t\t\t\t\treturn (o1.z ?? 0) - (o2.z ?? 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn l1 - l2;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t},\n\n\t\tevery<T>(t: Tag | Tag[] | ((obj: GameObj) => T), f?: (obj: GameObj) => T) {\n\t\t\tif (typeof t === \"function\" && f === undefined) {\n\t\t\t\treturn this.get().forEach((obj) => t(obj));\n\t\t\t} else if (typeof t === \"string\" || Array.isArray(t)) {\n\t\t\t\treturn this.get(t).forEach((obj) => f(obj));\n\t\t\t}\n\t\t},\n\n\t\trevery<T>(t: Tag | Tag[] | ((obj: GameObj) => T), f?: (obj: GameObj) => T) {\n\t\t\tif (typeof t === \"function\" && f === undefined) {\n\t\t\t\treturn this.get().reverse().forEach((obj) => t(obj));\n\t\t\t} else if (typeof t === \"string\" || Array.isArray(t)) {\n\t\t\t\treturn this.get(t).reverse().forEach((obj) => f(obj));\n\t\t\t}\n\t\t},\n\n\t\texists(): boolean {\n\t\t\tif (this.parent === game.root) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn this.parent?.exists();\n\t\t\t}\n\t\t},\n\n\t\tis(tag: Tag | Tag[]): boolean {\n\t\t\tif (tag === \"*\") {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (Array.isArray(tag)) {\n\t\t\t\tfor (const t of tag) {\n\t\t\t\t\tif (!this.c(t)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn this.c(tag) != null;\n\t\t\t}\n\t\t},\n\n\t\ton(ev: string, cb): EventCanceller {\n\t\t\tif (!events[ev]) {\n\t\t\t\tevents[ev] = new IDList();\n\t\t\t}\n\t\t\treturn events[ev].pushd(cb);\n\t\t},\n\n\t\taction(...args): EventCanceller {\n\t\t\tconsole.warn(\"action() is deprecated. Use onUpdate() instead\")\n\t\t\treturn this.onUpdate(...args);\n\t\t},\n\n\t\ttrigger(ev: string, ...args): void {\n\n\t\t\tif (events[ev]) {\n\t\t\t\tevents[ev].forEach((cb) => cb.call(this, ...args));\n\t\t\t}\n\n\t\t\tconst gEvents = game.objEvents[ev];\n\n\t\t\tif (gEvents) {\n\t\t\t\tgEvents.forEach((e) => {\n\t\t\t\t\tif (this.is(e.tag)) {\n\t\t\t\t\t\te.cb(this, ...args);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t},\n\n\t\tdestroy() {\n\t\t\tthis.parent?.remove(this);\n\t\t},\n\n\t\tinspect() {\n\t\t\tconst info = {};\n\t\t\tfor (const [tag, comp] of compStates) {\n\t\t\t\tinfo[tag] = comp.inspect ? comp.inspect() : null;\n\t\t\t}\n\t\t\treturn info;\n\t\t},\n\n\t\tonUpdate(cb: () => void): EventCanceller {\n\t\t\treturn this.on(\"update\", cb);\n\t\t},\n\n\t\tonDraw(cb: () => void): EventCanceller {\n\t\t\treturn this.on(\"draw\", cb);\n\t\t},\n\n\t\tonDestroy(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"destroy\", action);\n\t\t},\n\n\t\tclearEvents() {\n\t\t\tevents = {}\n\t\t},\n\n\t};\n\n\tfor (const comp of comps) {\n\t\tobj.use(comp);\n\t}\n\n\treturn obj as unknown as GameObj<T>;\n\n}\n\n// add an event to a tag\nfunction on(event: string, tag: Tag, cb: (obj: GameObj, ...args) => void): EventCanceller {\n\tif (!game.objEvents[event]) {\n\t\tgame.objEvents[event] = new IDList();\n\t}\n\treturn game.objEvents[event].pushd({\n\t\ttag: tag,\n\t\tcb: cb,\n\t});\n}\n\n// add update event to a tag or global update\nfunction onUpdate(tag: Tag | (() => void), cb?: (obj: GameObj) => void): EventCanceller {\n\tif (typeof tag === \"function\" && cb === undefined) {\n\t\treturn game.root.onUpdate(tag);\n\t} else if (typeof tag === \"string\") {\n\t\treturn on(\"update\", tag, cb);\n\t}\n}\n\n// add draw event to a tag or global draw\nfunction onDraw(tag: Tag | (() => void), cb?: (obj: GameObj) => void) {\n\tif (typeof tag === \"function\" && cb === undefined) {\n\t\treturn game.root.onDraw(tag);\n\t} else if (typeof tag === \"string\") {\n\t\treturn on(\"draw\", tag, cb);\n\t}\n}\n\n// add an event that runs with objs with t1 collides with objs with t2\nfunction onCollide(\n\tt1: Tag,\n\tt2: Tag,\n\tf: (a: GameObj, b: GameObj, col?: Collision) => void,\n): EventCanceller {\n\tconst e1 = on(\"collide\", t1, (a, b, col) => b.is(t2) && f(a, b, col));\n\tconst e2 = on(\"collide\", t2, (a, b, col) => b.is(t1) && f(b, a, col));\n\tconst e3 = onUpdate(t1, (o1: GameObj) => {\n\t\tif (!o1.area) {\n\t\t\tthrow new Error(\"onCollide() requires the object to have area() component\");\n\t\t}\n\t\to1._checkCollisions(t2, (o2) => {\n\t\t\tf(o1, o2);\n\t\t});\n\t});\n\treturn () => [e1, e2, e3].forEach((f) => f());\n}\n\n// add an event that runs when objs with tag t is clicked\nfunction onClick(tag: Tag | (() => void), cb?: (obj: GameObj) => void): EventCanceller {\n\tif (typeof tag === \"function\") {\n\t\treturn onMousePress(tag);\n\t} else {\n\t\treturn onUpdate(tag, (o: GameObj) => {\n\t\t\tif (!o.area) throw new Error(\"onClick() requires the object to have area() component\");\n\t\t\tif (o.isClicked()) {\n\t\t\t\tcb(o);\n\t\t\t}\n\t\t});\n\t}\n}\n\n// add an event that runs when objs with tag t is hovered\nfunction onHover(t: string, onHover: (obj: GameObj) => void, onNotHover?: (obj: GameObj) => void): EventCanceller {\n\treturn onUpdate(t, (o: GameObj) => {\n\t\tif (!o.area) throw new Error(\"onHover() requires the object to have area() component\");\n\t\tif (o.isHovering()) {\n\t\t\tonHover(o);\n\t\t} else {\n\t\t\tif (onNotHover) {\n\t\t\t\tonNotHover(o);\n\t\t\t}\n\t\t}\n\t});\n}\n\n// add an event that'd be run after t\nfunction wait(t: number, f?: () => void): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tgame.timers.push(new Timer(t, () => {\n\t\t\tif (f) f();\n\t\t\tresolve();\n\t\t}))\n\t});\n}\n\n// add an event that's run every t seconds\nfunction loop(t: number, f: () => void): EventCanceller {\n\n\tlet stopped = false;\n\n\tconst newF = () => {\n\t\tif (stopped) {\n\t\t\treturn;\n\t\t}\n\t\tf();\n\t\twait(t, newF);\n\t};\n\n\tnewF();\n\n\treturn () => stopped = true;\n\n}\n\n// input callbacks\nfunction onKeyDown(k: Key | Key[], f: () => void): EventCanceller {\n\tif (Array.isArray(k)) {\n\t\tconst cancellers = k.map((key) => onKeyDown(key, f));\n\t\treturn () => cancellers.forEach((cb) => cb());\n\t} {\n\t\treturn game.on(\"input\", () => isKeyDown(k) && f());\n\t}\n}\n\nfunction onKeyPress(k: Key | Key[] | (() => void), f?: () => void): EventCanceller {\n\tif (Array.isArray(k)) {\n\t\tconst cancellers = k.map((key) => onKeyPress(key, f));\n\t\treturn () => cancellers.forEach((cb) => cb());\n\t} else if (typeof k === \"function\") {\n\t\treturn game.on(\"input\", () => isKeyPressed() && k());\n\t} else {\n\t\treturn game.on(\"input\", () => isKeyPressed(k) && f());\n\t}\n}\n\nfunction onKeyPressRepeat(k: Key | Key[] | (() => void), f?: () => void): EventCanceller {\n\tif (Array.isArray(k)) {\n\t\tconst cancellers = k.map((key) => onKeyPressRepeat(key, f));\n\t\treturn () => cancellers.forEach((cb) => cb());\n\t} else if (typeof k === \"function\") {\n\t\treturn game.on(\"input\", () => isKeyPressed() && k());\n\t} else {\n\t\treturn game.on(\"input\", () => isKeyPressedRepeat(k) && f());\n\t}\n}\n\nfunction onKeyRelease(k: Key | Key[] | (() => void), f?: () => void): EventCanceller {\n\tif (Array.isArray(k)) {\n\t\tconst cancellers = k.map((key) => onKeyRelease(key, f));\n\t\treturn () => cancellers.forEach((cb) => cb());\n\t} else if (typeof k === \"function\") {\n\t\treturn game.on(\"input\", () => isKeyReleased() && k());\n\t} else {\n\t\treturn game.on(\"input\", () => isKeyReleased(k) && f());\n\t}\n}\n\nfunction onMouseDown(\n\tm: MouseButton | ((pos?: Vec2) => void),\n\taction?: (pos?: Vec2) => void\n): EventCanceller {\n\tif (typeof m === \"function\") {\n\t\treturn game.on(\"input\", () => isMouseDown() && m(mousePos()));\n\t} else {\n\t\treturn game.on(\"input\", () => isMouseDown(m) && action(mousePos()));\n\t}\n}\n\nfunction onMousePress(\n\tm: MouseButton | ((pos?: Vec2) => void),\n\taction?: (pos?: Vec2) => void\n): EventCanceller {\n\tif (typeof m === \"function\") {\n\t\treturn game.on(\"input\", () => isMousePressed() && m(mousePos()));\n\t} else {\n\t\treturn game.on(\"input\", () => isMousePressed(m) && action(mousePos()));\n\t}\n}\n\nfunction onMouseRelease(\n\tm: MouseButton | ((pos?: Vec2) => void),\n\taction?: (pos?: Vec2) => void\n): EventCanceller {\n\tif (typeof m === \"function\") {\n\t\treturn game.on(\"input\", () => isMouseReleased() && m(mousePos()));\n\t} else {\n\t\treturn game.on(\"input\", () => isMouseReleased(m) && action(mousePos()));\n\t}\n}\n\nfunction onMouseMove(f: (pos: Vec2, dpos: Vec2) => void): EventCanceller {\n\treturn game.on(\"input\", () => isMouseMoved() && f(mousePos(), mouseDeltaPos()));\n}\n\nfunction onCharInput(f: (ch: string) => void): EventCanceller {\n\treturn game.on(\"input\", () => charInputted().forEach((ch) => f(ch)));\n}\n\nfunction onTouchStart(f: (id: TouchID, pos: Vec2) => void): EventCanceller {\n\treturn game.on(\"onTouchStart\", f);\n}\n\nfunction onTouchMove(f: (id: TouchID, pos: Vec2) => void): EventCanceller {\n\treturn game.on(\"onTouchMove\", f);\n}\n\nfunction onTouchEnd(f: (id: TouchID, pos: Vec2) => void): EventCanceller {\n\treturn game.on(\"onTouchEnd\", f);\n}\n\nfunction enterDebugMode() {\n\n\tonKeyPress(\"f1\", () => {\n\t\tdebug.inspect = !debug.inspect;\n\t});\n\n\tonKeyPress(\"f2\", () => {\n\t\tdebug.clearLog();\n\t});\n\n\tonKeyPress(\"f8\", () => {\n\t\tdebug.paused = !debug.paused;\n\t});\n\n\tonKeyPress(\"f7\", () => {\n\t\tdebug.timeScale = toFixed(clamp(debug.timeScale - 0.2, 0, 2), 1);\n\t});\n\n\tonKeyPress(\"f9\", () => {\n\t\tdebug.timeScale = toFixed(clamp(debug.timeScale + 0.2, 0, 2), 1);\n\t});\n\n\tonKeyPress(\"f10\", () => {\n\t\tdebug.stepFrame();\n\t});\n\n\tonKeyPress(\"f5\", () => {\n\t\tdownloadURL(screenshot(), \"kaboom.png\");\n\t});\n\n\tonKeyPress(\"f6\", () => {\n\t\tif (debug.curRecording) {\n\t\t\tdebug.curRecording.download();\n\t\t\tdebug.curRecording = null;\n\t\t} else {\n\t\t\tdebug.curRecording = record();\n\t\t}\n\t});\n\n}\n\nfunction enterBurpMode() {\n\tonKeyPress(\"b\", burp);\n}\n\n// get / set gravity\nfunction gravity(g?: number): number {\n\tif (g !== undefined) {\n\t\tgame.gravity = g;\n\t}\n\treturn game.gravity;\n}\n\nfunction regCursor(c: Cursor, draw: string | ((mpos: Vec2) => void)) {\n\t// TODO\n}\n\nfunction makeCollision(target: GameObj<any>, dis: Vec2): Collision {\n\treturn {\n\t\ttarget: target,\n\t\tdisplacement: dis,\n\t\tisTop: () => dis.y > 0,\n\t\tisBottom: () => dis.y < 0,\n\t\tisLeft: () => dis.x > 0,\n\t\tisRight: () => dis.x < 0,\n\t};\n}\n\n// TODO: manage global velocity here?\nfunction pos(...args): PosComp {\n\n\treturn {\n\n\t\tid: \"pos\",\n\t\tpos: vec2(...args),\n\n\t\t// TODO: clean\n\t\tmoveBy(...args): Collision | null {\n\n\t\t\tconst p = vec2(...args);\n\t\t\tlet dx = p.x;\n\t\t\tlet dy = p.y;\n\t\t\tlet col = null;\n\n\t\t\tif (this.solid && this.area?.shape === \"rect\") {\n\n\t\t\t\tlet a1 = this.worldArea();\n\n\t\t\t\t// TODO: definitely shouln't iterate through all solid objs\n\t\t\t\tgame.root.every((other) => {\n\n\t\t\t\t\t// make sure we still exist, don't check with self, and only\n\t\t\t\t\t// check with other solid objects\n\t\t\t\t\tif (\n\t\t\t\t\t\t!this.exists()\n\t\t\t\t\t\t|| other === this\n\t\t\t\t\t\t|| !other.solid\n\t\t\t\t\t\t|| other.area?.shape !== \"rect\"\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst a2 = other.worldArea();\n\t\t\t\t\tlet md = minkDiff(a2, a1);\n\n\t\t\t\t\t// if they're already overlapping, push them away first\n\t\t\t\t\tif (testRectPoint(md, vec2(0))) {\n\n\t\t\t\t\t\tlet dist = Math.min(\n\t\t\t\t\t\t\tMath.abs(md.p1.x),\n\t\t\t\t\t\t\tMath.abs(md.p2.x),\n\t\t\t\t\t\t\tMath.abs(md.p1.y),\n\t\t\t\t\t\t\tMath.abs(md.p2.y),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst res = (() => {\n\t\t\t\t\t\t\tswitch (dist) {\n\t\t\t\t\t\t\t\tcase Math.abs(md.p1.x): return vec2(dist, 0);\n\t\t\t\t\t\t\t\tcase Math.abs(md.p2.x): return vec2(-dist, 0);\n\t\t\t\t\t\t\t\tcase Math.abs(md.p1.y): return vec2(0, dist);\n\t\t\t\t\t\t\t\tcase Math.abs(md.p2.y): return vec2(0, -dist);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})();\n\n\t\t\t\t\t\tthis.pos = this.pos.sub(res);\n\n\t\t\t\t\t\t// calculate new mink diff\n\t\t\t\t\t\ta1 = this.worldArea();\n\t\t\t\t\t\tmd = minkDiff(a2, a1);\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst ray = { p1: vec2(0), p2: vec2(dx, dy) };\n\t\t\t\t\tlet minT = 1;\n\t\t\t\t\tconst p1 = md.p1;\n\t\t\t\t\tconst p2 = vec2(md.p1.x, md.p2.y);\n\t\t\t\t\tconst p3 = md.p2;\n\t\t\t\t\tconst p4 = vec2(md.p2.x, md.p1.y);\n\t\t\t\t\tlet numCols = 0;\n\t\t\t\t\tconst lines = {\n\t\t\t\t\t\t\"right\": { p1: p1, p2: p2, },\n\t\t\t\t\t\t\"top\": { p1: p2, p2: p3, },\n\t\t\t\t\t\t\"left\": { p1: p3, p2: p4, },\n\t\t\t\t\t\t\"bottom\": { p1: p4, p2: p1, },\n\t\t\t\t\t};\n\n\t\t\t\t\tfor (const s in lines) {\n\t\t\t\t\t\tconst line = lines[s];\n\t\t\t\t\t\t// if moving along a side, we forgive\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(dx === 0 && line.p1.x === 0 && line.p2.x === 0)\n\t\t\t\t\t\t\t||\n\t\t\t\t\t\t\t(dy === 0 && line.p1.y === 0 && line.p2.y === 0)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tminT = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst t = testLineLineT(ray, line);\n\t\t\t\t\t\tif (t != null) {\n\t\t\t\t\t\t\tnumCols++;\n\t\t\t\t\t\t\tif (t < minT) {\n\t\t\t\t\t\t\t\tminT = t;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// if moving away, we forgive\n\t\t\t\t\tif (\n\t\t\t\t\t\tminT < 1\n\t\t\t\t\t\t&& !(minT === 0 && numCols == 1 && !testRectPoint(md, vec2(dx, dy)))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst dis = vec2(-dx * (1 - minT), -dy * (1 - minT));\n\t\t\t\t\t\tdx *= minT;\n\t\t\t\t\t\tdy *= minT;\n\t\t\t\t\t\tcol = makeCollision(other, dis);\n\t\t\t\t\t}\n\n\t\t\t\t});\n\n\t\t\t}\n\n\t\t\tthis.pos.x += dx;\n\t\t\tthis.pos.y += dy;\n\n\t\t\tif (col) {\n\t\t\t\tthis.trigger(\"collide\", col.target, col);\n\t\t\t\tcol.target.trigger(\"collide\", this, makeCollision(this, col.displacement.scale(-1)));\n\t\t\t}\n\n\t\t\treturn col;\n\n\t\t},\n\n\t\t// move with velocity (pixels per second)\n\t\tmove(...args): Collision | null {\n\t\t\treturn this.moveBy(vec2(...args).scale(dt()));\n\t\t},\n\n\t\t// move to a destination, with optional speed\n\t\tmoveTo(...args) {\n\t\t\tif (typeof args[0] === \"number\" && typeof args[1] === \"number\") {\n\t\t\t\treturn this.moveTo(vec2(args[0], args[1]), args[2]);\n\t\t\t}\n\t\t\tconst dest = args[0];\n\t\t\tconst speed = args[1];\n\t\t\tif (speed === undefined) {\n\t\t\t\tthis.pos = vec2(dest);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst diff = dest.sub(this.pos);\n\t\t\tif (diff.len() <= speed * dt()) {\n\t\t\t\tthis.pos = vec2(dest);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.move(diff.unit().scale(speed));\n\t\t},\n\n\t\t// TODO\n\t\t// get the screen position (transformed by camera)\n\t\tscreenPos(): Vec2 {\n\t\t\tif (this.fixed) {\n\t\t\t\treturn this.pos;\n\t\t\t} else {\n\t\t\t\treturn toScreen(this.pos);\n\t\t\t}\n\t\t},\n\n\t\tinspect() {\n\t\t\treturn `(${Math.round(this.pos.x)}, ${Math.round(this.pos.y)})`;\n\t\t},\n\n\t};\n\n};\n\n// TODO: allow single number assignment\nfunction scale(...args): ScaleComp {\n\tif (args.length === 0) {\n\t\treturn scale(1);\n\t}\n\treturn {\n\t\tid: \"scale\",\n\t\tscale: vec2(...args),\n\t\tscaleTo(...args) {\n\t\t\tthis.scale = vec2(...args);\n\t\t},\n\t\tinspect() {\n\t\t\tif (typeof this.scale === \"number\") {\n\t\t\t\treturn `${toFixed(this.scale, 2)}`;\n\t\t\t} else {\n\t\t\t\treturn `(${toFixed(this.scale.x, 2)}, ${toFixed(this.scale.y, 2)})`;\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction rotate(r: number): RotateComp {\n\treturn {\n\t\tid: \"rotate\",\n\t\tangle: r ?? 0,\n\t\tinspect() {\n\t\t\treturn `${Math.round(this.angle)}`;\n\t\t},\n\t};\n}\n\nfunction color(...args): ColorComp {\n\treturn {\n\t\tid: \"color\",\n\t\tcolor: rgb(...args),\n\t\tinspect() {\n\t\t\treturn this.color.str();\n\t\t},\n\t};\n}\n\nfunction toFixed(n: number, f: number) {\n\treturn Number(n.toFixed(f));\n}\n\nfunction opacity(a: number): OpacityComp {\n\treturn {\n\t\tid: \"opacity\",\n\t\topacity: a ?? 1,\n\t\tinspect() {\n\t\t\treturn `${toFixed(this.opacity, 2)}`;\n\t\t},\n\t};\n}\n\nfunction origin(o: Origin | Vec2): OriginComp {\n\tif (!o) {\n\t\tthrow new Error(\"please define an origin\");\n\t}\n\treturn {\n\t\tid: \"origin\",\n\t\torigin: o,\n\t\tinspect() {\n\t\t\tif (typeof this.origin === \"string\") {\n\t\t\t\treturn this.origin;\n\t\t\t} else {\n\t\t\t\treturn this.origin.str();\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction layer(l: string): LayerComp {\n\treturn {\n\t\tid: \"layer\",\n\t\tlayer: l,\n\t\tinspect() {\n\t\t\treturn this.layer ?? game.defLayer;\n\t\t},\n\t};\n}\n\nfunction z(z: number): ZComp {\n\treturn {\n\t\tid: \"z\",\n\t\tz: z,\n\t\tinspect() {\n\t\t\treturn `${this.z}`;\n\t\t},\n\t};\n}\n\nfunction follow(obj: GameObj, offset?: Vec2): FollowComp {\n\treturn {\n\t\tid: \"follow\",\n\t\trequire: [ \"pos\", ],\n\t\tfollow: {\n\t\t\tobj: obj,\n\t\t\toffset: offset ?? vec2(0),\n\t\t},\n\t\tadd() {\n\t\t\tif (obj.exists()) {\n\t\t\t\tthis.pos = this.follow.obj.pos.add(this.follow.offset);\n\t\t\t}\n\t\t},\n\t\tupdate() {\n\t\t\tif (obj.exists()) {\n\t\t\t\tthis.pos = this.follow.obj.pos.add(this.follow.offset);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction move(dir: number | Vec2, speed: number): MoveComp {\n\tconst d = typeof dir === \"number\" ? Vec2.fromAngle(dir) : dir.unit();\n\treturn {\n\t\tid: \"move\",\n\t\trequire: [ \"pos\", ],\n\t\tupdate() {\n\t\t\tthis.move(d.scale(speed));\n\t\t},\n\t};\n}\n\nfunction outview(opt: OutviewCompOpt = {}): OutviewComp {\n\tlet timer = 0;\n\tlet isOut = false;\n\treturn {\n\t\tid: \"outview\",\n\t\trequire: [ \"pos\", \"area\", ],\n\t\tisOutOfView(): boolean {\n\t\t\tconst offset = vec2(opt.offset ?? 0);\n\t\t\tconst screenRect = new Rect(\n\t\t\t\tvec2(0, 0).sub(offset),\n\t\t\t\tvec2(width(), height()).add(offset),\n\t\t\t);\n\t\t\treturn !testAreaRect(this.screenArea(), screenRect);\n\t\t},\n\t\tonExitView(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"exitView\", action);\n\t\t},\n\t\tonEnterView(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"enterView\", action);\n\t\t},\n\t\tupdate() {\n\t\t\tif (this.isOutOfView()) {\n\t\t\t\tif (!isOut) {\n\t\t\t\t\tthis.trigger(\"exitView\");\n\t\t\t\t\tisOut = true;\n\t\t\t\t}\n\t\t\t\tif (opt.delay) {\n\t\t\t\t\ttimer += dt();\n\t\t\t\t\tif (timer < opt.delay) return\n\t\t\t\t}\n\t\t\t\tif (opt.hide) this.hidden = true;\n\t\t\t\tif (opt.pause) this.paused = true;\n\t\t\t\tif (opt.destroy) this.destroy();\n\t\t\t} else {\n\t\t\t\tif (isOut) {\n\t\t\t\t\tthis.trigger(\"enterView\");\n\t\t\t\t\tisOut = false;\n\t\t\t\t}\n\t\t\t\ttimer = 0;\n\t\t\t\tif (opt.hide) this.hidden = false;\n\t\t\t\tif (opt.pause) this.paused = false;\n\t\t\t}\n\t\t},\n\t\tinspect() {\n\t\t\treturn this.isOutOfView();\n\t\t},\n\t};\n}\n\nfunction cleanup(opt: (number | undefined) | CleanupCompOpt = {}): CleanupComp {\n\tif (typeof opt === \"number\") {\n\t\tdeprecateMsg(\"clean(time)\", \"cleanup({ delay: time })\");\n\t\treturn {\n\t\t\t...outview({\n\t\t\t\tdestroy: true,\n\t\t\t\tdelay: opt,\n\t\t\t}),\n\t\t\tid: \"cleanup\",\n\t\t};\n\t}\n\treturn {\n\t\t...outview({\n\t\t\tdestroy: true,\n\t\t\tonExitView: opt.onCleanup,\n\t\t\toffset: opt.offset,\n\t\t\tdelay: opt.delay,\n\t\t}),\n\t\tid: \"cleanup\",\n\t};\n}\n\nfunction area(opt: AreaCompOpt = {}): AreaComp {\n\n\tconst colliding = {};\n\n\treturn {\n\n\t\tid: \"area\",\n\n\t\tadd() {\n\t\t\tif (this.area.cursor) {\n\t\t\t\t// TODO: collect\n\t\t\t\tthis.onHover(() => cursor(this.area.cursor));\n\t\t\t}\n\t\t},\n\n\t\tarea: {\n\t\t\tshape: \"rect\",\n\t\t\toffset: opt.offset ?? vec2(0),\n\t\t\twidth: opt.width,\n\t\t\theight: opt.height,\n\t\t\tscale: opt.scale ?? vec2(1),\n\t\t\tcursor: opt.cursor,\n\t\t},\n\n\t\tisClicked(): boolean {\n\t\t\treturn isMousePressed() && this.isHovering();\n\t\t},\n\n\t\tisHovering() {\n\t\t\tconst mpos = this.fixed ? mousePos() : toWorld(mousePos());\n\t\t\treturn this.hasPoint(mpos);\n\t\t},\n\n\t\tisColliding(other) {\n\t\t\tif (!other.area || !other.exists()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst a1 = this.worldArea();\n\t\t\tconst a2 = other.worldArea();\n\t\t\treturn testAreaArea(a1, a2);\n\t\t},\n\n\t\tisTouching(other) {\n\t\t\tif (!other.area || !other.exists()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// TODO: support other shapes\n\t\t\tconst a1 = this.worldArea();\n\t\t\tconst a2 = other.worldArea();\n\t\t\treturn testRectRect2(a1, a2);\n\t\t},\n\n\t\tonClick(f: () => void): EventCanceller {\n\t\t\treturn this.onUpdate(() => {\n\t\t\t\tif (this.isClicked()) {\n\t\t\t\t\tf();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tonHover(onHover: () => void, onNotHover: () => void): EventCanceller {\n\t\t\treturn this.onUpdate(() => {\n\t\t\t\tif (this.isHovering()) {\n\t\t\t\t\tonHover();\n\t\t\t\t} else {\n\t\t\t\t\tif (onNotHover) {\n\t\t\t\t\t\tonNotHover();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tonCollide(tag: Tag, f: (o: GameObj, col?: Collision) => void): EventCanceller {\n\t\t\tconst e1 = this.onUpdate(() => this._checkCollisions(tag, f));\n\t\t\tconst e2 = this.on(\"collide\", (obj, col) => obj.is(tag) && f(obj, col));\n\t\t\treturn () => [e1, e2].forEach((f) => f());\n\t\t},\n\n\t\tclicks(...args) {\n\t\t\tdeprecateMsg(\"clicks()\", \"onClick()\");\n\t\t\treturn this.onClick(...args);\n\t\t},\n\n\t\thovers(...args) {\n\t\t\tdeprecateMsg(\"hovers()\", \"onHover()\");\n\t\t\treturn this.onHover(...args);\n\t\t},\n\n\t\tcollides(...args) {\n\t\t\tdeprecateMsg(\"collides()\", \"onCollide()\");\n\t\t\treturn this.onCollide(...args);\n\t\t},\n\n\t\thasPoint(pt: Vec2): boolean {\n\t\t\treturn testAreaPoint(this.worldArea(), pt);\n\t\t},\n\n\t\t// push an obj out of another if they're overlapped\n\t\tpushOut(obj: GameObj): Vec2 | null {\n\n\t\t\tif (obj === this) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// TODO: support other shapes\n\t\t\tif (obj.area?.shape !== \"rect\") {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst a1 = this.worldArea();\n\t\t\tconst a2 = obj.worldArea();\n\t\t\tconst md = minkDiff(a1, a2);\n\n\t\t\tif (!testRectPoint(md, vec2(0))) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet dist = Math.min(\n\t\t\t\tMath.abs(md.p1.x),\n\t\t\t\tMath.abs(md.p2.x),\n\t\t\t\tMath.abs(md.p1.y),\n\t\t\t\tMath.abs(md.p2.y),\n\t\t\t);\n\n\t\t\tconst res = (() => {\n\t\t\t\tswitch (dist) {\n\t\t\t\t\tcase Math.abs(md.p1.x): return vec2(dist, 0);\n\t\t\t\t\tcase Math.abs(md.p2.x): return vec2(-dist, 0);\n\t\t\t\t\tcase Math.abs(md.p1.y): return vec2(0, dist);\n\t\t\t\t\tcase Math.abs(md.p2.y): return vec2(0, -dist);\n\t\t\t\t}\n\t\t\t})();\n\n\t\t\tthis.pos = this.pos.add(res);\n\n\t\t},\n\n\t\t// push object out of other solid objects\n\t\tpushOutAll() {\n\t\t\tgame.root.every(this.pushOut);\n\t\t},\n\n\t\t// @ts-ignore\n\t\t_checkCollisions(tag: Tag) {\n\n\t\t\tgame.root.every(tag, (obj) => {\n\n\t\t\t\tif (this === obj || !this.exists() || colliding[obj._id]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (this.isColliding(obj)) {\n\t\t\t\t\tthis.trigger(\"collide\", obj, null);\n\t\t\t\t\tcolliding[obj._id] = obj;\n\t\t\t\t}\n\n\t\t\t});\n\n\t\t\tfor (const id in colliding) {\n\t\t\t\tconst obj = colliding[id];\n\t\t\t\tif (!this.isColliding(obj)) {\n\t\t\t\t\tdelete colliding[id];\n\t\t\t\t}\n\t\t\t}\n\n\t\t},\n\n\t\t// TODO: doesn't work with nested parent transforms\n\t\t// TODO: cache\n\t\t// TODO: use matrix mult for more accuracy and rotation?\n\t\tworldArea(): Area {\n\n\t\t\tlet w = this.area.width ?? this.width;\n\t\t\tlet h = this.area.height ?? this.height;\n\n\t\t\tif (w == null || h == null) {\n\t\t\t\tthrow new Error(\"failed to get area dimension\");\n\t\t\t}\n\n\t\t\tconst scale = vec2(this.scale ?? 1).scale(this.area.scale);\n\n\t\t\tw *= scale.x;\n\t\t\th *= scale.y;\n\n\t\t\tconst orig = originPt(this.origin || DEF_ORIGIN);\n\t\t\tconst pos = (this.pos ?? vec2(0))\n\t\t\t\t.add(this.area.offset)\n\t\t\t\t.sub(orig.add(1, 1).scale(0.5).scale(w, h));\n\n\t\t\treturn {\n\t\t\t\tshape: \"rect\",\n\t\t\t\tp1: pos,\n\t\t\t\tp2: vec2(pos.x + w, pos.y + h),\n\t\t\t};\n\n\t\t},\n\n\t\tscreenArea(): Area {\n\t\t\tconst area = this.worldArea();\n\t\t\tif (this.fixed) {\n\t\t\t\treturn area;\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tshape: \"rect\",\n\t\t\t\t\tp1: toScreen(area.p1),\n\t\t\t\t\tp2: toScreen(area.p2),\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t};\n\n}\n\n// make the list of common render properties from the \"pos\", \"scale\", \"color\", \"opacity\", \"rotate\", \"origin\", \"outline\", and \"shader\" components of a character\nfunction getRenderProps(obj: GameObj<any>) {\n\treturn {\n\t\tcolor: obj.color,\n\t\topacity: obj.opacity,\n\t\torigin: obj.origin,\n\t\toutline: obj.outline,\n\t\tfixed: obj.fixed,\n\t\tshader: assets.shaders[obj.shader],\n\t\tuniform: obj.uniform,\n\t};\n}\n\ninterface SpriteCurAnim {\n\tname: string,\n\ttimer: number,\n\tloop: boolean,\n\tspeed: number,\n\tpingpong: boolean,\n\tonEnd: () => void,\n}\n\n// TODO: clean\nfunction sprite(id: string | SpriteData, opt: SpriteCompOpt = {}): SpriteComp {\n\n\tlet spr = null;\n\tlet curAnim: SpriteCurAnim | null = null;\n\n\tfunction calcTexScale(tex: GfxTexture, q: Quad, w?: number, h?: number): Vec2 {\n\t\tconst scale = vec2(1, 1);\n\t\tif (w && h) {\n\t\t\tscale.x = w / (tex.width * q.w);\n\t\t\tscale.y = h / (tex.height * q.h);\n\t\t} else if (w) {\n\t\t\tscale.x = w / (tex.width * q.w);\n\t\t\tscale.y = scale.x;\n\t\t} else if (h) {\n\t\t\tscale.y = h / (tex.height * q.h);\n\t\t\tscale.x = scale.y;\n\t\t}\n\t\treturn scale;\n\t}\n\n\treturn {\n\n\t\tid: \"sprite\",\n\t\t// TODO: allow update\n\t\twidth: 0,\n\t\theight: 0,\n\t\tframe: opt.frame || 0,\n\t\tquad: opt.quad || new Quad(0, 0, 1, 1),\n\t\tanimSpeed: opt.animSpeed ?? 1,\n\n\t\tload() {\n\n\t\t\tif (typeof id === \"string\") {\n\t\t\t\tspr = assets.sprites[id];\n\t\t\t} else {\n\t\t\t\tspr = id;\n\t\t\t}\n\n\t\t\tif (!spr) {\n\t\t\t\tthrow new Error(`sprite not found: \"${id}\"`);\n\t\t\t}\n\n\t\t\tlet q = spr.frames[0].clone();\n\n\t\t\tif (opt.quad) {\n\t\t\t\tq = q.scale(opt.quad);\n\t\t\t}\n\n\t\t\tconst scale = calcTexScale(spr.tex, q, opt.width, opt.height);\n\n\t\t\tthis.width = spr.tex.width * q.w * scale.x;\n\t\t\tthis.height = spr.tex.height * q.h * scale.y;\n\n\t\t\tif (opt.anim) {\n\t\t\t\tthis.play(opt.anim);\n\t\t\t}\n\n\t\t},\n\n\t\tdraw() {\n\t\t\tdrawSprite({\n\t\t\t\t...getRenderProps(this),\n\t\t\t\tsprite: spr,\n\t\t\t\tframe: this.frame,\n\t\t\t\tquad: this.quad,\n\t\t\t\tflipX: opt.flipX,\n\t\t\t\tflipY: opt.flipY,\n\t\t\t\ttiled: opt.tiled,\n\t\t\t\twidth: opt.width,\n\t\t\t\theight: opt.height,\n\t\t\t});\n\t\t},\n\n\t\tupdate() {\n\n\t\t\tif (!curAnim) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst anim = spr.anims[curAnim.name];\n\n\t\t\tif (typeof anim === \"number\") {\n\t\t\t\tthis.frame = anim;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (anim.speed === 0) {\n\t\t\t\tthrow new Error(\"sprite anim speed cannot be 0\");\n\t\t\t}\n\n\t\t\tcurAnim.timer += dt() * this.animSpeed;\n\n\t\t\tif (curAnim.timer >= (1 / curAnim.speed)) {\n\t\t\t\tcurAnim.timer = 0;\n\t\t\t\t// TODO: clean up\n\t\t\t\tif (anim.from > anim.to) {\n\t\t\t\t\tthis.frame--;\n\t\t\t\t\tif (this.frame < anim.to) {\n\t\t\t\t\t\tif (curAnim.loop) {\n\t\t\t\t\t\t\tthis.frame = anim.from;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.frame++;\n\t\t\t\t\t\t\tcurAnim.onEnd();\n\t\t\t\t\t\t\tthis.stop();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.frame++;\n\t\t\t\t\tif (this.frame > anim.to) {\n\t\t\t\t\t\tif (curAnim.loop) {\n\t\t\t\t\t\t\tthis.frame = anim.from;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.frame--;\n\t\t\t\t\t\t\tcurAnim.onEnd();\n\t\t\t\t\t\t\tthis.stop();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t},\n\n\t\t// TODO: this opt should be used instead of the sprite data opt, if given\n\t\tplay(name: string, opt: SpriteAnimPlayOpt = {}) {\n\n\t\t\tif (!spr) {\n\t\t\t\tonLoad(() => {\n\t\t\t\t\tthis.play(name);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst anim = spr.anims[name];\n\n\t\t\tif (anim == null) {\n\t\t\t\tthrow new Error(`anim not found: ${name}`);\n\t\t\t}\n\n\t\t\tif (curAnim) {\n\t\t\t\tthis.stop();\n\t\t\t}\n\n\t\t\tcurAnim = {\n\t\t\t\tname: name,\n\t\t\t\ttimer: 0,\n\t\t\t\tloop: opt.loop ?? anim.loop ?? false,\n\t\t\t\tpingpong: opt.pingpong ?? anim.pingpong ?? false,\n\t\t\t\tspeed: opt.speed ?? anim.speed ?? 10,\n\t\t\t\tonEnd: opt.onEnd ?? (() => {}),\n\t\t\t};\n\n\t\t\tif (typeof anim === \"number\") {\n\t\t\t\tthis.frame = anim;\n\t\t\t} else {\n\t\t\t\tthis.frame = anim.from;\n\t\t\t}\n\n\t\t\t// TODO: \"animPlay\" is deprecated\n\t\t\tthis.trigger(\"animPlay\", name);\n\t\t\tthis.trigger(\"animStart\", name);\n\n\t\t},\n\n\t\tstop() {\n\t\t\tif (!curAnim) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst prevAnim = curAnim.name;\n\t\t\tcurAnim = null;\n\t\t\tthis.trigger(\"animEnd\", prevAnim);\n\t\t},\n\n\t\tnumFrames() {\n\t\t\tif (!spr) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn spr.frames.length;\n\t\t},\n\n\t\tcurAnim() {\n\t\t\treturn curAnim?.name;\n\t\t},\n\n\t\tflipX(b: boolean) {\n\t\t\topt.flipX = b;\n\t\t},\n\n\t\tflipY(b: boolean) {\n\t\t\topt.flipY = b;\n\t\t},\n\n\t\tonAnimEnd(name: string, action: () => void): EventCanceller {\n\t\t\treturn this.on(\"animEnd\", (anim) => {\n\t\t\t\tif (anim === name) {\n\t\t\t\t\taction();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tonAnimStart(name: string, action: () => void): EventCanceller {\n\t\t\treturn this.on(\"animStart\", (anim) => {\n\t\t\t\tif (anim === name) {\n\t\t\t\t\taction();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tinspect() {\n\t\t\tlet msg = \"\";\n\t\t\tif (typeof id === \"string\") {\n\t\t\t\tmsg += JSON.stringify(id);\n\t\t\t} else {\n\t\t\t\tmsg += \"[blob]\";\n\t\t\t}\n\t\t\treturn msg;\n\t\t},\n\n\t};\n\n}\n\nfunction text(t: string, opt: TextCompOpt = {}): TextComp {\n\n\tfunction update(obj: GameObj<TextComp | any>) {\n\n\t\tconst ftext = formatText({\n\t\t\t...getRenderProps(obj),\n\t\t\ttext: obj.text + \"\",\n\t\t\tsize: obj.textSize,\n\t\t\tfont: obj.font,\n\t\t\twidth: opt.width && obj.width,\n\t\t\tletterSpacing: obj.letterSpacing,\n\t\t\tlineSpacing: obj.lineSpacing,\n\t\t\ttransform: obj.transform,\n\t\t\tstyles: obj.styles,\n\t\t});\n\n\t\tobj.width = ftext.width / (obj.scale?.x || 1);\n\t\tobj.height = ftext.height / (obj.scale?.y || 1);\n\n\t\treturn ftext;\n\n\t};\n\n\treturn {\n\n\t\tid: \"text\",\n\t\ttext: t,\n\t\ttextSize: opt.size,\n\t\tfont: opt.font,\n\t\twidth: opt.width,\n\t\theight: 0,\n\t\tlineSpacing: opt.lineSpacing,\n\t\tletterSpacing: opt.letterSpacing,\n\t\ttransform: opt.transform,\n\t\tstyles: opt.styles,\n\n\t\tload() {\n\t\t\tupdate(this);\n\t\t},\n\n\t\tdraw() {\n\t\t\tdrawFormattedText(update(this));\n\t\t},\n\n\t};\n\n}\n\nfunction rect(w: number, h: number, opt: RectCompOpt = {}): RectComp {\n\treturn {\n\t\tid: \"rect\",\n\t\twidth: w,\n\t\theight: h,\n\t\tradius: opt.radius || 0,\n\t\tdraw() {\n\t\t\tdrawRect({\n\t\t\t\t...getRenderProps(this),\n\t\t\t\twidth: this.width,\n\t\t\t\theight: this.height,\n\t\t\t\tradius: this.radius,\n\t\t\t});\n\t\t},\n\t\tinspect() {\n\t\t\treturn `${Math.ceil(this.width)}, ${Math.ceil(this.height)}`;\n\t\t},\n\t};\n}\n\nfunction uvquad(w: number, h: number): UVQuadComp {\n\treturn {\n\t\tid: \"rect\",\n\t\twidth: w,\n\t\theight: h,\n\t\tdraw() {\n\t\t\tdrawUVQuad({\n\t\t\t\t...getRenderProps(this),\n\t\t\t\twidth: this.width,\n\t\t\t\theight: this.height,\n\t\t\t});\n\t\t},\n\t\tinspect() {\n\t\t\treturn `${Math.ceil(this.width)}, ${Math.ceil(this.height)}`;\n\t\t},\n\t};\n}\n\nfunction circle(radius: number): CircleComp {\n\treturn {\n\t\tid: \"circle\",\n\t\tradius: radius,\n\t\tdraw() {\n\t\t\tdrawCircle({\n\t\t\t\t...getRenderProps(this),\n\t\t\t\tradius: this.radius,\n\t\t\t});\n\t\t},\n\t\tinspect() {\n\t\t\treturn `${Math.ceil(this.radius)}`;\n\t\t},\n\t};\n}\n\nfunction outline(width: number = 1, color: Color = rgb(0, 0, 0)): OutlineComp {\n\treturn {\n\t\tid: \"outline\",\n\t\toutline: {\n\t\t\twidth,\n\t\t\tcolor,\n\t\t},\n\t};\n}\n\nfunction timer(time?: number, action?: () => void): TimerComp {\n\tconst timers: IDList<Timer> = new IDList();\n\tif (time && action) {\n\t\ttimers.pushd(new Timer(time, action));\n\t}\n\treturn {\n\t\tid: \"timer\",\n\t\twait(time: number, action: () => void): EventCanceller {\n\t\t\treturn timers.pushd(new Timer(time, action));\n\t\t},\n\t\tupdate() {\n\t\t\ttimers.forEach((timer, id) => {\n\t\t\t\tif (timer.tick(dt())) {\n\t\t\t\t\ttimers.delete(id);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n\n// maximum y velocity with body()\nconst DEF_JUMP_FORCE = 640;\nconst MAX_VEL = 65536;\n\n// TODO: land on wall\nfunction body(opt: BodyCompOpt = {}): BodyComp {\n\n\tlet velY = 0;\n\tlet curPlatform: GameObj | null = null;\n\tlet lastPlatformPos = null;\n\tlet canDouble = true;\n\n\treturn {\n\n\t\tid: \"body\",\n\t\trequire: [ \"pos\", \"area\", ],\n\t\tjumpForce: opt.jumpForce ?? DEF_JUMP_FORCE,\n\t\tweight: opt.weight ?? 1,\n\t\tsolid: opt.solid ?? true,\n\n\t\tupdate() {\n\n\t\t\tlet justFall = false;\n\n\t\t\t// check if loses current platform\n\t\t\tif (curPlatform) {\n\n\t\t\t\tconst a1 = this.worldArea();\n\t\t\t\tconst a2 = curPlatform.worldArea();\n\t\t\t\tconst y1 = a1.p2.y;\n\t\t\t\tconst y2 = a2.p1.y;\n\t\t\t\tconst x1 = a1.p1.x;\n\t\t\t\tconst x2 = a1.p2.x;\n\t\t\t\tconst x3 = a2.p1.x;\n\t\t\t\tconst x4 = a2.p2.x;\n\n\t\t\t\tif (\n\t\t\t\t\t!curPlatform.exists()\n\t\t\t\t\t|| y1 !== y2\n\t\t\t\t\t|| x2 < x3\n\t\t\t\t\t|| x1 > x4\n\t\t\t\t) {\n\t\t\t\t\tthis.trigger(\"fall\", curPlatform);\n\t\t\t\t\tcurPlatform = null;\n\t\t\t\t\tlastPlatformPos = null;\n\t\t\t\t\tjustFall = true;\n\t\t\t\t} else {\n\t\t\t\t\tif (lastPlatformPos && curPlatform.pos) {\n\t\t\t\t\t\t// TODO: moveBy?\n\t\t\t\t\t\t// sticky platform\n\t\t\t\t\t\tthis.pos = this.pos.add(curPlatform.pos.sub(lastPlatformPos));\n\t\t\t\t\t\tlastPlatformPos = curPlatform.pos.clone();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!curPlatform) {\n\n\t\t\t\tconst col = this.move(0, velY);\n\n\t\t\t\t// check if grounded to a new platform\n\t\t\t\tif (col) {\n\t\t\t\t\tif (col.isBottom()) {\n\t\t\t\t\t\tcurPlatform = col.target;\n\t\t\t\t\t\tconst oy = velY;\n\t\t\t\t\t\tvelY = 0;\n\t\t\t\t\t\tif (curPlatform.pos) {\n\t\t\t\t\t\t\tlastPlatformPos = curPlatform.pos.clone();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!justFall) {\n\t\t\t\t\t\t\tthis.trigger(\"ground\", curPlatform);\n\t\t\t\t\t\t\tcanDouble = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (col.isTop()) {\n\t\t\t\t\t\tvelY = 0;\n\t\t\t\t\t\tthis.trigger(\"headbutt\", col.target);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvelY += gravity() * this.weight * dt();\n\t\t\t\tvelY = Math.min(velY, opt.maxVel ?? MAX_VEL);\n\n\t\t\t}\n\n\t\t},\n\n\t\tcurPlatform(): GameObj | null {\n\t\t\treturn curPlatform;\n\t\t},\n\n\t\tisGrounded() {\n\t\t\treturn curPlatform !== null;\n\t\t},\n\n\t\tgrounded(): boolean {\n\t\t\tdeprecateMsg(\"grounded()\", \"isGrounded()\");\n\t\t\treturn this.isGrounded();\n\t\t},\n\n\t\tisFalling(): boolean {\n\t\t\treturn velY > 0;\n\t\t},\n\n\t\tfalling(): boolean {\n\t\t\tdeprecateMsg(\"falling()\", \"isFalling()\");\n\t\t\treturn this.isFalling();\n\t\t},\n\n\t\tjump(force: number) {\n\t\t\tcurPlatform = null;\n\t\t\tlastPlatformPos = null;\n\t\t\tvelY = -force || -this.jumpForce;\n\t\t},\n\n\t\tdoubleJump(force: number) {\n\t\t\tif (this.isGrounded()) {\n\t\t\t\tthis.jump(force);\n\t\t\t} else if (canDouble) {\n\t\t\t\tcanDouble = false;\n\t\t\t\tthis.jump(force);\n\t\t\t\tthis.trigger(\"doubleJump\");\n\t\t\t}\n\t\t},\n\n\t\tonGround(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"ground\", action);\n\t\t},\n\n\t\tonFall(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"fall\", action);\n\t\t},\n\n\t\tonHeadbutt(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"headbutt\", action);\n\t\t},\n\n\t\tonDoubleJump(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"doubleJump\", action);\n\t\t},\n\n\t};\n\n}\n\nfunction shader(id: string, uniform: Uniform = {}): ShaderComp {\n\tconst shader = assets.shaders[id];\n\treturn {\n\t\tid: \"shader\",\n\t\tshader: id,\n\t\tuniform: uniform,\n\t};\n}\n\nfunction solid(): SolidComp {\n\treturn {\n\t\tid: \"solid\",\n\t\trequire: [ \"area\", ],\n\t\tsolid: true,\n\t};\n}\n\nfunction fixed(): FixedComp {\n\treturn {\n\t\tid: \"fixed\",\n\t\tfixed: true,\n\t};\n}\n\nfunction stay(): StayComp {\n\treturn {\n\t\tid: \"stay\",\n\t\tstay: true,\n\t};\n}\n\nfunction health(hp: number): HealthComp {\n\tif (hp == null) {\n\t\tthrow new Error(\"health() requires the initial amount of hp\");\n\t}\n\treturn {\n\t\tid: \"health\",\n\t\thurt(n: number = 1) {\n\t\t\tthis.setHP(hp - n);\n\t\t\tthis.trigger(\"hurt\");\n\t\t},\n\t\theal(n: number = 1) {\n\t\t\tthis.setHP(hp + n);\n\t\t\tthis.trigger(\"heal\");\n\t\t},\n\t\thp(): number {\n\t\t\treturn hp;\n\t\t},\n\t\tsetHP(n: number) {\n\t\t\thp = n;\n\t\t\tif (hp <= 0) {\n\t\t\t\tthis.trigger(\"death\");\n\t\t\t}\n\t\t},\n\t\tonHurt(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"hurt\", action);\n\t\t},\n\t\tonHeal(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"heal\", action);\n\t\t},\n\t\tonDeath(action: () => void): EventCanceller {\n\t\t\treturn this.on(\"death\", action);\n\t\t},\n\t\tinspect() {\n\t\t\treturn `${hp}`;\n\t\t},\n\t};\n}\n\nfunction lifespan(time: number, opt: LifespanCompOpt = {}): LifespanComp {\n\tif (time == null) {\n\t\tthrow new Error(\"lifespan() requires time\");\n\t}\n\tlet timer = 0;\n\tconst fade = opt.fade ?? 0;\n\tconst startFade = Math.max((time - fade), 0);\n\treturn {\n\t\tid: \"lifespan\",\n\t\tupdate() {\n\t\t\ttimer += dt();\n\t\t\t// TODO: don't assume 1 as start opacity\n\t\t\tif (timer >= startFade) {\n\t\t\t\tthis.opacity = map(timer, startFade, time, 1, 0);\n\t\t\t}\n\t\t\tif (timer >= time) {\n\t\t\t\tthis.destroy();\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction state(\n\tinitState: string,\n\tstateList?: string[],\n\ttransitions?: Record<string, string | string[]>,\n): StateComp {\n\n\tif (!initState) {\n\t\tthrow new Error(\"state() requires an initial state\");\n\t}\n\n\tconst events = {};\n\n\tfunction initStateHook(state: string) {\n\t\tif (!events[state]) {\n\t\t\tevents[state] = {\n\t\t\t\tenter: [],\n\t\t\t\tleave: [],\n\t\t\t\tupdate: [],\n\t\t\t\tdraw: [],\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction on(event, state, action) {\n\t\tinitStateHook(state);\n\t\tevents[state][event].push(action);\n\t}\n\n\tfunction trigger(event, state, ...args) {\n\t\tinitStateHook(state);\n\t\tevents[state][event].forEach((action) => action(...args));\n\t}\n\n\treturn {\n\n\t\tid: \"state\",\n\t\tstate: initState,\n\n\t\tenterState(state: string, ...args) {\n\n\t\t\tif (stateList && !stateList.includes(state)) {\n\t\t\t\tthrow new Error(`State not found: ${state}`);\n\t\t\t}\n\n\t\t\tconst oldState = this.state;\n\n\t\t\tif (transitions) {\n\n\t\t\t\t// check if the transition is legal, if transition graph is defined\n\t\t\t\tif (!transitions?.[oldState]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst available = typeof transitions[oldState] === \"string\"\n\t\t\t\t\t? [transitions[oldState]]\n\t\t\t\t\t: transitions[oldState] as string[];\n\n\t\t\t\tif (!available.includes(state)) {\n\t\t\t\t\tthrow new Error(`Cannot transition state from \"${oldState}\" to \"${state}\". Available transitions: ${available.map((s) => `\"${s}\"`).join(\", \")}`);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttrigger(\"leave\", oldState, ...args);\n\t\t\tthis.state = state;\n\t\t\ttrigger(\"enter\", state, ...args);\n\t\t\ttrigger(\"enter\", `${oldState} -> ${state}`, ...args);\n\n\t\t},\n\n\t\tonStateTransition(from: string, to: string, action: () => void) {\n\t\t\ton(\"enter\", `${from} -> ${to}`, action);\n\t\t},\n\n\t\tonStateEnter(state: string, action: () => void) {\n\t\t\ton(\"enter\", state, action);\n\t\t},\n\n\t\tonStateUpdate(state: string, action: () => void) {\n\t\t\ton(\"update\", state, action);\n\t\t},\n\n\t\tonStateDraw(state: string, action: () => void) {\n\t\t\ton(\"draw\", state, action);\n\t\t},\n\n\t\tonStateLeave(state: string, action: () => void) {\n\t\t\ton(\"leave\", state, action);\n\t\t},\n\n\t\tupdate() {\n\t\t\ttrigger(\"update\", this.state);\n\t\t},\n\n\t\tdraw() {\n\t\t\ttrigger(\"draw\", this.state);\n\t\t},\n\n\t\tinspect() {\n\t\t\treturn this.state;\n\t\t},\n\n\t};\n\n}\n\nfunction onLoad(cb: () => void): void {\n\tif (app.loaded) {\n\t\tcb();\n\t} else {\n\t\tgame.on(\"load\", cb);\n\t}\n}\n\nfunction scene(id: SceneID, def: SceneDef) {\n\tgame.scenes[id] = def;\n}\n\nfunction go(id: SceneID, ...args) {\n\n\tif (!game.scenes[id]) {\n\t\tthrow new Error(`scene not found: ${id}`);\n\t}\n\n\tconst cancel = game.on(\"updateStart\", () => {\n\n\t\tgame.events = {};\n\n\t\tgame.objEvents = {\n\t\t\tadd: new IDList(),\n\t\t\tupdate: new IDList(),\n\t\t\tdraw: new IDList(),\n\t\t\tdestroy: new IDList(),\n\t\t};\n\n\t\tgame.root.every((obj) => {\n\t\t\tif (!obj.is(\"stay\")) {\n\t\t\t\tgame.root.remove(obj);\n\t\t\t}\n\t\t})\n\n\t\tgame.root.clearEvents();\n\t\tgame.timers = new IDList();\n\n\t\t// cam\n\t\tgame.cam = {\n\t\t\tpos: center(),\n\t\t\tscale: vec2(1),\n\t\t\tangle: 0,\n\t\t\tshake: 0,\n\t\t\ttransform: new Mat4(),\n\t\t};\n\n\t\tgame.layers = {};\n\t\tgame.defLayer = null;\n\t\tgame.gravity = DEF_GRAVITY;\n\n\t\tgame.scenes[id](...args);\n\n\t\tif (gopt.debug !== false) {\n\t\t\tenterDebugMode();\n\t\t}\n\n\t\tif (gopt.burp) {\n\t\t\tenterBurpMode();\n\t\t}\n\n\t\tcancel();\n\n\t});\n\n}\n\nfunction getData<T>(key: string, def?: T): T {\n\ttry {\n\t\treturn JSON.parse(window.localStorage[key]);\n\t} catch {\n\t\tif (def) {\n\t\t\tsetData(key, def);\n\t\t\treturn def;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n\nfunction setData(key: string, data: any) {\n\twindow.localStorage[key] = JSON.stringify(data);\n}\n\nfunction plug<T>(plugin: KaboomPlugin<T>): MergeObj<T> & KaboomCtx {\n\tconst funcs = plugin(ctx);\n\tfor (const k in funcs) {\n\t\t// @ts-ignore\n\t\tctx[k] = funcs[k];\n\t\tif (gopt.global !== false) {\n\t\t\t// @ts-ignore\n\t\t\twindow[k] = funcs[k];\n\t\t}\n\t}\n\treturn ctx as unknown as MergeObj<T> & KaboomCtx;\n}\n\nfunction center(): Vec2 {\n\treturn vec2(width() / 2, height() / 2);\n}\n\nfunction grid(level: Level, p: Vec2) {\n\n\treturn {\n\n\t\tid: \"grid\",\n\t\tgridPos: p.clone(),\n\n\t\tsetGridPos(...args) {\n\t\t\tconst p = vec2(...args);\n\t\t\tthis.gridPos = p.clone();\n\t\t\tthis.pos = vec2(\n\t\t\t\tlevel.offset().x + this.gridPos.x * level.gridWidth(),\n\t\t\t\tlevel.offset().y + this.gridPos.y * level.gridHeight()\n\t\t\t);\n\t\t},\n\n\t\tmoveLeft() {\n\t\t\tthis.setGridPos(this.gridPos.add(vec2(-1, 0)));\n\t\t},\n\n\t\tmoveRight() {\n\t\t\tthis.setGridPos(this.gridPos.add(vec2(1, 0)));\n\t\t},\n\n\t\tmoveUp() {\n\t\t\tthis.setGridPos(this.gridPos.add(vec2(0, -1)));\n\t\t},\n\n\t\tmoveDown() {\n\t\t\tthis.setGridPos(this.gridPos.add(vec2(0, 1)));\n\t\t},\n\n\t};\n\n}\n\nfunction addLevel(map: string[], opt: LevelOpt): Level {\n\n\tif (!opt.width || !opt.height) {\n\t\tthrow new Error(\"Must provide level grid width & height.\");\n\t}\n\n\tconst objs: GameObj[] = [];\n\tconst offset = vec2(opt.pos || vec2(0));\n\tlet longRow = 0;\n\n\tconst level = {\n\n\t\toffset() {\n\t\t\treturn offset.clone();\n\t\t},\n\n\t\tgridWidth() {\n\t\t\treturn opt.width;\n\t\t},\n\n\t\tgridHeight() {\n\t\t\treturn opt.height;\n\t\t},\n\n\t\tgetPos(...args): Vec2 {\n\t\t\tconst p = vec2(...args);\n\t\t\treturn vec2(\n\t\t\t\toffset.x + p.x * opt.width,\n\t\t\t\toffset.y + p.y * opt.height\n\t\t\t);\n\t\t},\n\n\t\tspawn(sym: string, ...args): GameObj {\n\n\t\t\tconst p = vec2(...args);\n\n\t\t\tconst comps = (() => {\n\t\t\t\tif (opt[sym]) {\n\t\t\t\t\tif (typeof opt[sym] !== \"function\") {\n\t\t\t\t\t\tthrow new Error(\"level symbol def must be a function returning a component list\");\n\t\t\t\t\t}\n\t\t\t\t\treturn opt[sym](p);\n\t\t\t\t} else if (opt.any) {\n\t\t\t\t\treturn opt.any(sym, p);\n\t\t\t\t}\n\t\t\t})();\n\n\t\t\tif (!comps) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst posComp = vec2(\n\t\t\t\toffset.x + p.x * opt.width,\n\t\t\t\toffset.y + p.y * opt.height\n\t\t\t);\n\n\t\t\tfor (const comp of comps) {\n\t\t\t\tif (comp.id === \"pos\") {\n\t\t\t\t\tposComp.x += comp.pos.x;\n\t\t\t\t\tposComp.y += comp.pos.y;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcomps.push(pos(posComp));\n\t\t\tcomps.push(grid(this, p));\n\n\t\t\tconst obj = game.root.add(comps);\n\n\t\t\tobjs.push(obj);\n\n\t\t\treturn obj;\n\n\t\t},\n\n\t\twidth() {\n\t\t\treturn longRow * opt.width;\n\t\t},\n\n\t\theight() {\n\t\t\treturn map.length * opt.height;\n\t\t},\n\n\t\tdestroy() {\n\t\t\tfor (const obj of objs) {\n\t\t\t\tobj.destroy();\n\t\t\t}\n\t\t},\n\n\t};\n\n\tmap.forEach((row, i) => {\n\n\t\tconst syms = row.split(\"\");\n\n\t\tlongRow = Math.max(syms.length, longRow);\n\n\t\tsyms.forEach((sym, j) => {\n\t\t\tlevel.spawn(sym, vec2(j, i));\n\t\t});\n\n\t});\n\n\treturn level;\n\n}\n\nfunction record(frameRate?): Recording {\n\n\tconst stream = app.canvas.captureStream(frameRate);\n\tconst audioDest = audio.ctx.createMediaStreamDestination();\n\n\taudio.masterNode.connect(audioDest)\n\n\tconst audioStream = audioDest.stream;\n\tconst [firstAudioTrack] = audioStream.getAudioTracks();\n\n\t// TODO: Enabling audio results in empty video if no audio received\n\t// stream.addTrack(firstAudioTrack);\n\n\tconst recorder = new MediaRecorder(stream);\n\tconst chunks = [];\n\n\trecorder.ondataavailable = (e) => {\n\t\tif (e.data.size > 0) {\n\t\t\tchunks.push(e.data);\n\t\t}\n\t};\n\n\trecorder.onerror = (e) => {\n\t\taudio.masterNode.disconnect(audioDest)\n\t\tstream.getTracks().forEach(t => t.stop());\n\t};\n\n\trecorder.start();\n\n\treturn {\n\n\t\tresume() {\n\t\t\trecorder.resume();\n\t\t},\n\n\t\tpause() {\n\t\t\trecorder.pause();\n\t\t},\n\n\t\tdownload(filename = \"kaboom.mp4\") {\n\n\t\t\trecorder.onstop = () => {\n\t\t\t\tdownloadBlob(new Blob(chunks, {\n\t\t\t\t\ttype: \"video/mp4\",\n\t\t\t\t}), filename);\n\t\t\t}\n\n\t\t\trecorder.stop();\n\t\t\t// cleanup\n\t\t\taudio.masterNode.disconnect(audioDest)\n\t\t\tstream.getTracks().forEach(t => t.stop());\n\n\t\t},\n\n\t};\n\n}\n\nfunction focus() {\n\tdeprecateMsg(\"focus()\", \"canvas.focus()\");\n\tapp.canvas.focus();\n}\n\nfunction isFocused(): boolean {\n\treturn document.activeElement === app.canvas;\n}\n\ninterface BoomOpt {\n\t/**\n\t * Animation speed.\n\t */\n\tspeed?: number,\n\t/**\n\t * Scale.\n\t */\n\tscale?: number,\n\t/**\n\t * Additional ka components.\n\t */\n\tkaComps?: () => CompList<any>,\n\t/**\n\t * Additional boom components.\n\t */\n\tboomComps?: () => CompList<any>,\n}\n\n// aliases for root game obj operations\nfunction add<T>(comps: CompList<T>): GameObj<T> {\n\treturn game.root.add(comps);\n}\n\nfunction readd<T>(obj: GameObj<T>): GameObj<T> {\n\treturn game.root.readd(obj);\n}\n\nfunction destroy(obj: GameObj) {\n\treturn game.root.remove(obj);\n}\n\nfunction destroyAll(tag: Tag) {\n\treturn game.root.removeAll(tag);\n}\n\nfunction get(...args) {\n\treturn game.root.get(...args);\n}\n\nfunction every(...args) {\n\t// @ts-ignore\n\treturn game.root.every(...args);\n}\n\nfunction revery(...args) {\n\t// @ts-ignore\n\treturn game.root.revery(...args);\n}\n\ninterface ExplodeComp extends Comp {\n}\n\nfunction explode(speed: number = 2, size: number = 1): ExplodeComp {\n\tlet time = 0;\n\treturn {\n\t\tid: \"explode\",\n\t\trequire: [ \"scale\", ],\n\t\tupdate() {\n\t\t\tconst s = Math.sin(time * speed) * size;\n\t\t\tif (s < 0) {\n\t\t\t\tdestroy(this);\n\t\t\t}\n\t\t\tthis.scale = vec2(s);\n\t\t\ttime += dt();\n\t\t},\n\t};\n}\n\nlet kaSprite = null;\nlet boomSprite = null;\n\nloadSprite(null, kaSrc).then((spr) => kaSprite = spr);\nloadSprite(null, boomSrc).then((spr) => boomSprite = spr);\n\n// TODO: use children obj\nfunction addKaboom(p: Vec2, opt: BoomOpt = {}): Kaboom {\n\n\tconst speed = (opt.speed || 1) * 5;\n\tconst s = opt.scale || 1;\n\n\tconst boom = add([\n\t\tpos(p),\n\t\tsprite(boomSprite),\n\t\tscale(0),\n\t\tstay(),\n\t\torigin(\"center\"),\n\t\texplode(speed, s),\n\t\t...(opt.boomComps ?? (() => []))(),\n\t]);\n\n\tconst ka = add([\n\t\tpos(p),\n\t\tsprite(kaSprite),\n\t\tscale(0),\n\t\tstay(),\n\t\torigin(\"center\"),\n\t\ttimer(0.4 / speed, () => ka.use(explode(speed, s))),\n\t\t...(opt.kaComps ?? (() => []))(),\n\t]);\n\n\treturn {\n\t\tdestroy() {\n\t\t\tdestroy(ka);\n\t\t\tdestroy(boom);\n\t\t},\n\t};\n\n}\n\nfunction frames() {\n\treturn app.numFrames;\n}\n\nfunction updateFrame() {\n\n\tgame.trigger(\"updateStart\");\n\n\t// update timers\n\tgame.timers.forEach((t, id) => {\n\t\tt.time -= dt();\n\t\tif (t.time <= 0) {\n\t\t\t// TODO: some timer action causes crash on FF when dt is really high, not sure why\n\t\t\tt.action();\n\t\t\tgame.timers.delete(id);\n\t\t}\n\t});\n\n\t// update every obj\n\tgame.root.update();\n\n}\n\nfunction drawFrame() {\n\n\t// calculate camera matrix\n\tconst cam = game.cam;\n\tconst shake = Vec2.fromAngle(rand(0, 360)).scale(cam.shake);\n\n\tcam.shake = lerp(cam.shake, 0, 5 * dt());\n\tcam.transform = new Mat4()\n\t\t.translate(center())\n\t\t.scale(cam.scale)\n\t\t.rotateZ(cam.angle)\n\t\t.translate(cam.pos.scale(-1).add(shake))\n\t\t;\n\n\tgame.root.draw();\n\n}\n\nfunction drawLoadScreen() {\n\n\t// if assets are not fully loaded, draw a progress bar\n\tconst progress = loadProgress();\n\n\tif (progress === 1) {\n\t\tapp.loaded = true;\n\t\tgame.trigger(\"load\");\n\t} else {\n\n\t\tconst w = width() / 2;\n\t\tconst h = 24 / app.scale;\n\t\tconst pos = vec2(width() / 2, height() / 2).sub(vec2(w / 2, h / 2));\n\n\t\tdrawRect({\n\t\t\tpos: vec2(0),\n\t\t\twidth: width(),\n\t\t\theight: height(),\n\t\t\tcolor: rgb(0, 0, 0),\n\t\t});\n\n\t\tdrawRect({\n\t\t\tpos: pos,\n\t\t\twidth: w,\n\t\t\theight: h,\n\t\t\tfill: false,\n\t\t\toutline: {\n\t\t\t\twidth: 4 / app.scale,\n\t\t\t},\n\t\t});\n\n\t\tdrawRect({\n\t\t\tpos: pos,\n\t\t\twidth: w * progress,\n\t\t\theight: h,\n\t\t});\n\n\t}\n\n}\n\nfunction drawInspectText(pos, txt) {\n\n\tconst pad = vec2(8);\n\n\tpushTransform();\n\tpushTranslate(pos);\n\tpushScale(1 / app.scale);\n\n\tconst ftxt = formatText({\n\t\ttext: txt,\n\t\tfont: assets.fonts[DBG_FONT],\n\t\tsize: 16,\n\t\tpos: pad,\n\t\tcolor: rgb(255, 255, 255),\n\t\tfixed: true,\n\t});\n\n\tconst bw = ftxt.width + pad.x * 2;\n\tconst bh = ftxt.height + pad.x * 2;\n\n\tif (pos.x + bw / app.scale >= width()) {\n\t\tpushTranslate(vec2(-bw, 0));\n\t}\n\n\tif (pos.y + bh / app.scale >= height()) {\n\t\tpushTranslate(vec2(0, -bh));\n\t}\n\n\tdrawRect({\n\t\twidth: bw,\n\t\theight: bh,\n\t\tcolor: rgb(0, 0, 0),\n\t\tradius: 4,\n\t\topacity: 0.8,\n\t\tfixed: true,\n\t});\n\n\tdrawFormattedText(ftxt);\n\tpopTransform();\n\n}\n\nfunction drawDebug() {\n\n\tif (debug.inspect) {\n\n\t\tlet inspecting = null;\n\t\tconst lcolor = Color.fromArray(gopt.inspectColor ?? [0, 0, 255]);\n\n\t\t// draw area outline\n\t\tgame.root.every((obj) => {\n\n\t\t\tif (!obj.area) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (obj.hidden) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!inspecting) {\n\t\t\t\tif (obj.isHovering()) {\n\t\t\t\t\tinspecting = obj;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst lwidth = (inspecting === obj ? 8 : 4);\n\t\t\tconst a = obj.worldArea();\n\t\t\tconst w = a.p2.x - a.p1.x;\n\t\t\tconst h = a.p2.y - a.p1.y;\n\n\t\t\tdrawRect({\n\t\t\t\tpos: a.p1,\n\t\t\t\twidth: w,\n\t\t\t\theight: h,\n\t\t\t\toutline: {\n\t\t\t\t\twidth: lwidth,\n\t\t\t\t\tcolor: lcolor,\n\t\t\t\t},\n\t\t\t\tfill: false,\n\t\t\t\tfixed: obj.fixed,\n\t\t\t});\n\n\t\t});\n\n\t\tif (inspecting) {\n\n\t\t\tconst lines = [];\n\t\t\tconst data = inspecting.inspect();\n\n\t\t\tfor (const tag in data) {\n\t\t\t\tif (data[tag]) {\n\t\t\t\t\tlines.push(`${tag}: ${data[tag]}`);\n\t\t\t\t} else {\n\t\t\t\t\tlines.push(`${tag}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdrawInspectText(mousePos(), lines.join(\"\\n\"));\n\n\t\t}\n\n\t\tdrawInspectText(vec2(8 / app.scale), `FPS: ${debug.fps()}`);\n\n\t}\n\n\tif (debug.paused) {\n\n\t\t// top right corner\n\t\tpushTransform();\n\t\tpushTranslate(width(), 0);\n\t\tpushScale(1 / app.scale);\n\t\tpushTranslate(-8, 8);\n\n\t\tconst size = 32;\n\n\t\t// bg\n\t\tdrawRect({\n\t\t\twidth: size,\n\t\t\theight: size,\n\t\t\torigin: \"topright\",\n\t\t\tcolor: rgb(0, 0, 0),\n\t\t\topacity: 0.8,\n\t\t\tradius: 4,\n\t\t\tfixed: true,\n\t\t});\n\n\t\t// pause icon\n\t\tfor (let i = 1; i <= 2; i++) {\n\t\t\tdrawRect({\n\t\t\t\twidth: 4,\n\t\t\t\theight: size * 0.6,\n\t\t\t\torigin: \"center\",\n\t\t\t\tpos: vec2(-size / 3 * i, size * 0.5),\n\t\t\t\tcolor: rgb(255, 255, 255),\n\t\t\t\tradius: 2,\n\t\t\t\tfixed: true,\n\t\t\t});\n\t\t}\n\n\t\tpopTransform();\n\n\t}\n\n\tif (debug.timeScale !== 1) {\n\n\t\t// bottom right corner\n\t\tpushTransform();\n\t\tpushTranslate(width(), height());\n\t\tpushScale(1 / app.scale);\n\t\tpushTranslate(-8, -8);\n\n\t\tconst pad = 8;\n\n\t\t// format text first to get text size\n\t\tconst ftxt = formatText({\n\t\t\ttext: debug.timeScale.toFixed(1),\n\t\t\tfont: assets.fonts[DBG_FONT],\n\t\t\tsize: 16,\n\t\t\tcolor: rgb(255, 255, 255),\n\t\t\tpos: vec2(-pad),\n\t\t\torigin: \"botright\",\n\t\t\tfixed: true,\n\t\t});\n\n\t\t// bg\n\t\tdrawRect({\n\t\t\twidth: ftxt.width + pad * 2 + pad * 4,\n\t\t\theight: ftxt.height + pad * 2,\n\t\t\torigin: \"botright\",\n\t\t\tcolor: rgb(0, 0, 0),\n\t\t\topacity: 0.8,\n\t\t\tradius: 4,\n\t\t\tfixed: true,\n\t\t});\n\n\t\t// fast forward / slow down icon\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tconst flipped = debug.timeScale < 1;\n\t\t\tdrawTriangle({\n\t\t\t\tp1: vec2(-ftxt.width - pad * (flipped ? 2 : 3.5), -pad),\n\t\t\t\tp2: vec2(-ftxt.width - pad * (flipped ? 2 : 3.5), -pad - ftxt.height),\n\t\t\t\tp3: vec2(-ftxt.width - pad * (flipped ? 3.5 : 2), -pad - ftxt.height / 2),\n\t\t\t\tpos: vec2(-i * pad * 1 + (flipped ? -pad * 0.5 : 0), 0),\n\t\t\t\tcolor: rgb(255, 255, 255),\n\t\t\t\tfixed: true,\n\t\t\t});\n\t\t}\n\n\t\t// text\n\t\tdrawFormattedText(ftxt);\n\n\t\tpopTransform();\n\n\t}\n\n\tif (debug.curRecording) {\n\n\t\tpushTransform();\n\t\tpushTranslate(0, height());\n\t\tpushScale(1 / app.scale);\n\t\tpushTranslate(24, -24);\n\n\t\tdrawCircle({\n\t\t\tradius: 12,\n\t\t\tcolor: rgb(255, 0, 0),\n\t\t\topacity: wave(0, 1, time() * 4),\n\t\t\tfixed: true,\n\t\t});\n\n\t\tpopTransform();\n\n\t}\n\n\tif (debug.showLog && game.logs.length > 0) {\n\n\t\tpushTransform();\n\t\tpushTranslate(0, height());\n\t\tpushScale(1 / app.scale);\n\t\tpushTranslate(8, -8);\n\n\t\tconst pad = 8;\n\t\tconst max = gopt.logMax ?? 1;\n\n\t\tif (game.logs.length > max) {\n\t\t\tgame.logs = game.logs.slice(0, max);\n\t\t}\n\n\t\tconst ftext = formatText({\n\t\t\ttext: game.logs.join(\"\\n\"),\n\t\t\tfont: assets.fonts[DBG_FONT],\n\t\t\tpos: vec2(pad, -pad),\n\t\t\torigin: \"botleft\",\n\t\t\tsize: 16,\n\t\t\twidth: width() * app.scale * 0.6,\n\t\t\tlineSpacing: pad / 2,\n\t\t\tfixed: true,\n\t\t\tstyles: {\n\t\t\t\t\"time\": { color: rgb(127, 127, 127) },\n\t\t\t\t\"info\": { color: rgb(255, 255, 255) },\n\t\t\t\t\"error\": { color: rgb(255, 0, 127) },\n\t\t\t},\n\t\t});\n\n\t\tdrawRect({\n\t\t\twidth: ftext.width + pad * 2,\n\t\t\theight: ftext.height + pad * 2,\n\t\t\torigin: \"botleft\",\n\t\t\tcolor: rgb(0, 0, 0),\n\t\t\tradius: 4,\n\t\t\topacity: 0.8,\n\t\t\tfixed: true,\n\t\t});\n\n\t\tdrawFormattedText(ftext);\n\t\tpopTransform();\n\n\t}\n\n}\n\nif (gopt.debug !== false) {\n\tenterDebugMode();\n}\n\nif (gopt.burp) {\n\tenterBurpMode();\n}\n\nwindow.addEventListener(\"error\", (e) => {\n\tdebug.error(`Error: ${e.error.message}`);\n\tquit();\n\trun(() => {\n\t\tif (loadProgress() === 1) {\n\t\t\tframeStart();\n\t\t\tdrawDebug();\n\t\t\tframeEnd();\n\t\t}\n\t});\n});\n\nfunction run(f: () => void) {\n\n\tconst frame = (t: number) => {\n\n\t\tif (document.visibilityState !== \"visible\") {\n\t\t\tapp.loopID = requestAnimationFrame(frame);\n\t\t\treturn;\n\t\t}\n\n\t\tconst realTime = t / 1000;\n\t\tconst realDt = realTime - app.realTime;\n\n\t\tapp.realTime = realTime;\n\n\t\tif (!app.skipTime) {\n\t\t\tapp.dt = realDt;\n\t\t\tapp.time += app.dt;\n\t\t\tapp.fpsCounter.tick(app.dt);\n\t\t}\n\n\t\tapp.skipTime = false;\n\t\tapp.numFrames++;\n\n\t\tf();\n\n\t\tfor (const k in app.keyStates) {\n\t\t\tapp.keyStates[k] = processButtonState(app.keyStates[k]);\n\t\t}\n\n\t\tfor (const m in app.mouseStates) {\n\t\t\tapp.mouseStates[m] = processButtonState(app.mouseStates[m]);\n\t\t}\n\n\t\tapp.charInputted = [];\n\t\tapp.isMouseMoved = false;\n\t\tapp.isKeyPressed = false;\n\t\tapp.isKeyPressedRepeat = false;\n\t\tapp.isKeyReleased = false;\n\t\tapp.loopID = requestAnimationFrame(frame);\n\n\t};\n\n\tapp.stopped = false;\n\tapp.loopID = requestAnimationFrame(frame);\n\n}\n\n// main game loop\nrun(() => {\n\n\t// running this every frame now mainly because isFullscreen() is not updated real time when requested fullscreen\n\tupdateViewport();\n\n\tif (!app.loaded) {\n\t\tframeStart();\n\t\tdrawLoadScreen();\n\t\tframeEnd();\n\t} else {\n\n\t\t// TODO: this gives the latest mousePos in input handlers but uses cam matrix from last frame\n\t\tgame.trigger(\"input\");\n\n\t\tif (!debug.paused) {\n\t\t\tupdateFrame();\n\t\t}\n\n\t\tframeStart();\n\t\tdrawFrame();\n\n\t\tif (gopt.debug !== false) {\n\t\t\tdrawDebug();\n\t\t}\n\n\t\tframeEnd();\n\n\t}\n\n});\n\nloadFont(\n\t\"apl386\",\n\tapl386Src,\n\t45,\n\t74,\n);\n\nloadFont(\n\t\"apl386o\",\n\tapl386oSrc,\n\t45,\n\t74,\n);\n\nloadFont(\n\t\"sink\",\n\tsinkSrc,\n\t6,\n\t8,\n\t{\n\t\tchars: `\u2588\u263A\u263B\u2665\u2666\u2663\u2660\u25CF\u25CB\u25AA\u25A1\u25A0\u25D8\u266A\u266B\u2261\u25BA\u25C4\u2302\u00DE\u00C0\u00DF\u00D7\u00A5\u2191\u2193\u2192\u2190\u25CC\u25CF\u25BC\u25B2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\\`abcdefghijklmnopqrstuvwxyz{|}~\u03A7\u2591\u2592\u2593\u1E00\u1E01\u1E02\u2502\u252C\u2524\u250C\u2510\u1E03\u1E04\u253C\u1E05\u1E06\u1E07\u1E08\u1E09\u1E0A\u1E0B\u1E0C\u2500\u251C\u2534\u2514\u2518\u1E0D\u1E0E\u205E\u1E0F\u1E10\u1E11\u1E12\u1E13\u1E14\u1E15\u1E16\u1E17\u1E18\u2584\u1E19\u1E1A\u1E1B\u1E1C\u2026\u1E1D\u1E1E\u1E1F\u1E20\u1E21\u1E22\u1E23\u1E24\u1E25\u1E26\u258C\u2590\u1E27\u1E28\u1E29\u1E2A\u1E2B\u1E2C\u1E2D\u1E2E\u1E2F\u1E30\u1E31\u1E32\u1E33\u1E34\u1E35\u1E36\u1E37\u1E38\u1E39\u1E3A\u1E3B\u1E3C\u1E3D\u1E3E\u1E3F\u1E40\u1E41\u1E42\u1E43\u1E44\u1E45\u1E46\u1E47\u1E48\u1E49\u1E4A\u1E4B\u1E4C\u1E4D\u1E4E\u1E4F\u1E50\u1E51\u1E52\u1E53\u1E54\u1E55\u1E56\u1E57\u1E58\u1E59\u1E5A\u1E5B\u1E5C\u1E5D\u1E5E\u1E5F\u1E60\u1E61\u1E62\u1E63\u1E64\u1E65\u1E66\u1E67\u1E68\u1E69\u1E6A\u1E6B\u1E6C\u1E6D\u1E6E\u1E6F\u1E70\u1E71\u1E72\u1E73\u1E74\u1E75\u1E76\u1E77\u1E78\u1E79\u1E7A\u1E7B\u1E7C`,\n\t}\n);\n\nloadFont(\n\t\"sinko\",\n\tsinkoSrc,\n\t8,\n\t10,\n);\n\nframeStart();\nframeEnd();\n\n// the exported ctx handle\nconst ctx: KaboomCtx = {\n\t// asset load\n\tloadRoot,\n\tloadSprite,\n\tloadSpriteAtlas,\n\tloadSound,\n\tloadFont,\n\tloadShader,\n\tloadAseprite,\n\tloadPedit,\n\tloadBean,\n\tload,\n\t// query\n\twidth,\n\theight,\n\tcenter,\n\tdt,\n\ttime,\n\tscreenshot,\n\trecord,\n\tisFocused,\n\tfocus,\n\tcursor,\n\tregCursor,\n\tfullscreen,\n\tisFullscreen,\n\tonLoad,\n\tisTouch: () => app.isTouch,\n\t// misc\n\tlayers,\n\tcamPos,\n\tcamScale,\n\tcamRot,\n\tshake,\n\ttoScreen,\n\ttoWorld,\n\tgravity,\n\t// obj\n\tadd,\n\treadd,\n\tdestroy,\n\tdestroyAll,\n\tget,\n\tevery,\n\trevery,\n\t// comps\n\tpos,\n\tscale,\n\trotate,\n\tcolor,\n\topacity,\n\torigin,\n\tlayer,\n\tarea,\n\tsprite,\n\ttext,\n\trect,\n\tcircle,\n\tuvquad,\n\toutline,\n\tbody,\n\tshader,\n\ttimer,\n\tsolid,\n\tfixed,\n\tstay,\n\thealth,\n\tlifespan,\n\tz,\n\tmove,\n\toutview,\n\tcleanup,\n\tfollow,\n\tstate,\n\t// group events\n\ton,\n\tonUpdate,\n\tonDraw,\n\tonCollide,\n\tonClick,\n\tonHover,\n\t// input\n\tonKeyDown,\n\tonKeyPress,\n\tonKeyPressRepeat,\n\tonKeyRelease,\n\tonMouseDown,\n\tonMousePress,\n\tonMouseRelease,\n\tonMouseMove,\n\tonCharInput,\n\tonTouchStart,\n\tonTouchMove,\n\tonTouchEnd,\n\tmousePos,\n\tmouseWorldPos,\n\tmouseDeltaPos,\n\tisKeyDown,\n\tisKeyPressed,\n\tisKeyPressedRepeat,\n\tisKeyReleased,\n\tisMouseDown,\n\tisMousePressed,\n\tisMouseReleased,\n\tisMouseMoved,\n\t// timer\n\tloop,\n\twait,\n\t// audio\n\tplay,\n\tvolume,\n\tburp,\n\taudioCtx: audio.ctx,\n\t// math\n\tTimer,\n\tLine,\n\tRect,\n\tCircle,\n\tVec2,\n\tColor,\n\tMat4,\n\tQuad,\n\tRNG,\n\trng,\n\trand,\n\trandi,\n\trandSeed,\n\tvec2,\n\trgb,\n\thsl2rgb,\n\tquad,\n\tchoose,\n\tchance,\n\tlerp,\n\tmap,\n\tmapc,\n\twave,\n\tdeg2rad,\n\trad2deg,\n\ttestAreaRect,\n\ttestAreaLine,\n\ttestAreaCircle,\n\ttestAreaPolygon,\n\ttestAreaPoint,\n\ttestAreaArea,\n\ttestLineLine,\n\ttestRectRect,\n\ttestRectLine,\n\ttestRectPoint,\n\ttestPolygonPoint,\n\ttestLinePolygon,\n\ttestPolygonPolygon,\n\ttestCircleCircle,\n\ttestCirclePoint,\n\ttestRectPolygon,\n\t// raw draw\n\tdrawSprite,\n\tdrawText,\n\tformatText,\n\tdrawRect,\n\tdrawLine,\n\tdrawLines,\n\tdrawTriangle,\n\tdrawCircle,\n\tdrawEllipse,\n\tdrawUVQuad,\n\tdrawPolygon,\n\tdrawFormattedText,\n\tpushTransform,\n\tpopTransform,\n\tpushTranslate,\n\tpushRotate: pushRotateZ,\n\tpushScale,\n\t// debug\n\tdebug,\n\t// scene\n\tscene,\n\tgo,\n\t// level\n\taddLevel,\n\t// storage\n\tgetData,\n\tsetData,\n\t// plugin\n\tplug,\n\t// char sets\n\tASCII_CHARS,\n\tCP437_CHARS,\n\t// dom\n\tcanvas: app.canvas,\n\t// misc\n\taddKaboom,\n\t// dirs\n\tLEFT: Vec2.LEFT,\n\tRIGHT: Vec2.RIGHT,\n\tUP: Vec2.UP,\n\tDOWN: Vec2.DOWN,\n\t// colors\n\tRED: Color.RED,\n\tGREEN: Color.GREEN,\n\tBLUE: Color.BLUE,\n\tYELLOW: Color.YELLOW,\n\tMAGENTA: Color.MAGENTA,\n\tCYAN: Color.CYAN,\n\tWHITE: Color.WHITE,\n\tBLACK: Color.BLACK,\n\t// deprecated\n\tkeyIsDown: deprecate(\"keyIsDown()\", \"isKeyDown()\", isKeyDown),\n\tkeyIsPressed: deprecate(\"keyIsPressed()\", \"isKeyPressed()\", isKeyPressed),\n\tkeyIsPressedRep: deprecate(\"keyIsPressedRep()\", \"isKeyPressedRepeat()\", isKeyPressedRepeat),\n\tkeyIsReleased: deprecate(\"keyIsReleased()\", \"isKeyReleased()\", isKeyReleased),\n\tmouseIsDown: deprecate(\"mouseIsDown()\", \"isMouseDown()\", isMouseDown),\n\tmouseIsClicked: deprecate(\"mouseIsClicked()\", \"isMousePressed()\", isMousePressed),\n\tmouseIsReleased: deprecate(\"mouseIsReleased()\", \"isMouseReleased()\", isMouseReleased),\n\tmouseIsMoved: deprecate(\"mouseIsMoved()\", \"isMouseMoved()\", isMouseMoved),\n\tdir: deprecate(\"dir()\", \"Vec2.fromAngle()\", Vec2.fromAngle),\n\taction: deprecate(\"action()\", \"onUpdate()\", onUpdate),\n\trender: deprecate(\"render()\", \"onDraw()\", onDraw),\n\tcollides: deprecate(\"collides()\", \"onCollide()\", onCollide),\n\tclicks: deprecate(\"clicks()\", \"onClick()\", onClick),\n\thovers: deprecate(\"hovers()\", \"onHover()\", onHover),\n\tkeyDown: deprecate(\"keyDown()\", \"onKeyDown()\", onKeyDown),\n\tkeyPress: deprecate(\"keyPress()\", \"onKeyPress()\", onKeyPress),\n\tkeyPressRep: deprecate(\"keyPressRep()\", \"onKeyPressRepeat()\", onKeyPressRepeat),\n\tkeyRelease: deprecate(\"keyRelease()\", \"onKeyRelease()\", onKeyRelease),\n\tmouseDown: deprecate(\"mouseDown()\", \"onMouseDown()\", onMouseDown),\n\tmouseClick: deprecate(\"mouseClick()\", \"onMousePress()\", onMousePress),\n\tmouseRelease: deprecate(\"mouseRelease()\", \"onMouseRelease()\", onMouseRelease),\n\tmouseMove: deprecate(\"mouseMove()\", \"onMouseMove()\", onMouseMove),\n\tcharInput: deprecate(\"charInput()\", \"onCharInput()\", onCharInput),\n\ttouchStart: deprecate(\"touchStart()\", \"onTouchStart()\", onTouchStart),\n\ttouchMove: deprecate(\"touchMove()\", \"onTouchMove()\", onTouchMove),\n\ttouchEnd: deprecate(\"touchEnd()\", \"onTouchEnd()\", onTouchEnd),\n\tfocused: deprecate(\"focused()\", \"isFocused()\", isFocused),\n\tready: deprecate(\"ready()\", \"onLoad()\", onLoad),\n};\n\nif (gopt.plugins) {\n\tgopt.plugins.forEach(plug);\n}\n\n// export everything to window if global is set\nif (gopt.global !== false) {\n\tfor (const k in ctx) {\n\t\twindow[k] = ctx[k];\n\t}\n}\n\nreturn ctx;\n\n};\n", "export var easings = { // Easings taken from https://easings.net/\n\tlinear: (x) => {\n\t\treturn x;\n\t},\n\teaseInSine: (x) => {\n\t\treturn 1 - Math.cos((x * Math.PI) / 2);\n\t},\n\teaseOutSine: (x) => {\n\t\treturn Math.sin((x * Math.PI) / 2);\n\t},\n\teaseInOutSine: (x) => {\n\t\treturn -(Math.cos(Math.PI * x) - 1) / 2;\n\t},\n\teaseInQuad: (x) => {\n\t\treturn x * x;\n\t},\n\teaseOutQuad: (x) => {\n\t\treturn 1 - (1 - x) * (1 - x);\n\t},\n\teaseInOutQuad: (x) => {\n\t\treturn x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;\n\t},\n\teaseInCubic: (x) => {\n\t\treturn x * x * x;\n\t},\n\teaseOutCubic: (x) => {\n\t\treturn 1 - Math.pow(1 - x, 3);\n\t},\n\teaseInOutCubic: (x) => {\n\t\treturn x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n\t},\n\teaseInQuart: (x) => {\n\t\treturn x * x * x * x;\n\t},\n\teaseOutQuart: (x) => {\n\t\treturn 1 - Math.pow(1 - x, 4);\n\t},\n\teaseInOutQuart: (x) => {\n\t\treturn x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2;\n\t},\n\teaseInQuint: (x) => {\n\t\treturn x * x * x * x * x;\n\t},\n\teaseOutQuint: (x) => {\n\t\treturn 1 - Math.pow(1 - x, 5);\n\t},\n\teaseInOutQuint: (x) => {\n\t\treturn x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;\n\t},\n\teaseInExpo: (x) => {\n\t\treturn x === 0 ? 0 : Math.pow(2, 10 * x - 10);\n\t},\n\teaseOutExpo: (x) => {\n\t\treturn x === 1 ? 1 : 1 - Math.pow(2, -10 * x);\n\t},\n\teaseInOutExpo: (x) => {\n\t\treturn x === 0\n\t ? 0\n \t: x === 1\n\t ? 1\n \t: x < 0.5 ? Math.pow(2, 20 * x - 10) / 2\n\t : (2 - Math.pow(2, -20 * x + 10)) / 2;\n\t},\n\teaseInCirc: (x) => {\n\t\treturn 1 - Math.sqrt(1 - Math.pow(x, 2));\n\t},\n\teaseOutCirc: (x) => {\n\t\treturn Math.sqrt(1 - Math.pow(x - 1, 2));\n\t},\n\teaseInOutCirc: (x) => {\n\t\treturn x < 0.5\n\t ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2\n \t: (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;\n\t},\n\teaseInBack: (x) => {\n\t\tconst c1 = 1.70158;\n\t\tconst c3 = c1 + 1;\n\t\treturn c3 * x * x * x - c1 * x * x;\n\t},\n\teaseOutBack: (x) => {\n\t\tconst c1 = 1.70158;\n\t\tconst c3 = c1 + 1;\n\t\treturn 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);\n\t},\n\teaseInOutBack: (x) => {\n\t\tconst c1 = 1.70158;\n\t\tconst c2 = c1 * 1.525;\n\t\treturn x < 0.5\n\t ? (Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2\n\t : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;\n\t},\n\teaseInBounce: (x) => {\n\t\treturn 1 - easings.easeOutBounce(1 - x);\n\t},\n\teaseOutBounce: (x) => {\n\t\tconst n1 = 7.5625;\n\t\tconst d1 = 2.75;\n\t\t\n\t\tif (x < 1 / d1) {\n\t\t return n1 * x * x;\n\t\t} else if (x < 2 / d1) {\n\t\t return n1 * (x -= 1.5 / d1) * x + 0.75;\n\t\t} else if (x < 2.5 / d1) {\n\t\t return n1 * (x -= 2.25 / d1) * x + 0.9375;\n\t\t} else {\n\t\t return n1 * (x -= 2.625 / d1) * x + 0.984375;\n\t\t}\n\t},\n\teaseInOutBounce: (x) => {\n\t\treturn x < 0.5\n\t ? (1 - easings.easeOutBounce(1 - 2 * x)) / 2\n\t : (1 + easings.easeOutBounce(2 * x - 1)) / 2;\n\t}\n}\n\nexport var tweentypes = {\n\tFOREVER: (t, st, tl) => {\n\t\tif (t - st >= tl) {\n\t\t\treturn \"FOREVER\";\n\t\t}\n\t\treturn \"CONTINUE\";\n\t},\n\tLERPFOREVER: (t, st, tl) => {\n\t\treturn \"LF\";\n\t},\n\tPINGPONG: (t, st, tl) => {\n\t\tif (t - st >= tl) {\n\t\t\treturn \"PING\";\n\t\t}\n\t\treturn \"CONTINUE\";\n\t},\n\tNORMAL: (t, st, tl) => {\n\t\tif (t - st >= tl) {\n\t\t\treturn \"CALLBACK\";\n\t\t}\n\t\treturn \"CONTINUE\";\n\t}\n}\n\nexport function tween(func, attrs, timeLen, minVal, maxVal, ease, type, onFinish) {\n\tvar minVal = minVal != undefined ? minVal : func[attrs[0]];\n\tvar ease = ease != undefined ? ease : easings.linear;\n\tvar type = type != undefined ? type : tweentypes.NORMAL;\n\tvar stTime = time();\n\tvar onFinish = onFinish != undefined ? onFinish : \"ud\";\n\tvar upd = onUpdate(() => {\n\t\tswitch (type(time(), stTime, timeLen)) {\n\t\t\tcase \"CALLBACK\":\n\t\t\t\tfor (h in attrs) {\n\t\t\t\t\tfunc[attrs[h]] = maxVal;\n\t\t\t\t}\n\t\t\t\tupd();\n\t\t\t\treturn onFinish == \"ud\" ? true : onFinish();\n\t\t\tcase \"FOREVER\":\n\t\t\t\tstTime = time();\n\t\t\t\tbreak;\n\t\t\tcase \"CONTINUE\":\n\t\t\t\tfor (h in attrs) {\n\t\t\t\t\tfunc[attrs[h]] = minVal;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"PING\":\n\t\t\t\tvar buffer = minVal;\n\t\t\t\tminVal = maxVal;\n\t\t\t\tmaxVal = buffer;\n\t\t\t\tstTime = time();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\tfor (i in attrs) {\n\t\t\tfunc[attrs[i]] = lerp(minVal, maxVal, ease((time() - stTime) / timeLen));\n\t\t}\n\t});\n}", "import kaboom from \"kaboom\"\nimport { easings, tween, tweentypes } from \"./easing.js\"\n\n// initialize context\nkaboom({\n width: 700,\n height: 400,\n\t\tbackground: [ 0, 0, 0 ],\n\t\tcrisp: true,\n\t touchToMouse: true\n});\n\nload(new Promise((resolve, reject) => {\n\tloadFont(\"unscii\", \"fonts/unscii_8x8.png\", 8, 8, {chars: \" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"});\n\t// Music\n\tloadSound(\"tutorial\", \"sounds/Getting it Done.mp3\"); //135\n\tloadSound(\"faith\", \"sounds/The Friendly Faith Plate.mp3\"); //120\n\tloadSound(\"sonic\", \"sounds/SonicInMidSim.wav\"); //139\n\tloadSound(\"green\", \"sounds/GreenHill.wav\"); //139\n\tloadSound(\"gameover\", \"sounds/gameover.mp3\");\n\t// \n\t\n\t// Sounds\n\tloadSound(\"score\", \"sounds/score.mp3\");\n\tloadSound(\"metro\", \"sounds/metro.wav\");\n\tloadSound(\"explode\", \"sounds/explode.mp3\");\n\t// \n\n\t//Menus\n\tloadSprite(\"bgCake\", \"sprites/bgCake.png\");\n\tloadSprite(\"jellybeanTitle\", \"sprites/jellybeanTitle.png\");\n\tloadSprite(\"logo\", \"sprites/logo.png\");\n\tloadSprite(\"jellybeanFail\", \"sprites/jellybeanFail.png\");\n\tloadSprite(\"keyA\", \"sprites/keyA.png\");\n\tloadSprite(\"keySpace\", \"sprites/keySpace.png\");\n\tloadSprite(\"keyClick\", \"sprites/keyClick.png\");\n\t// \n\t\n\t// Main Game\n\tloadSprite(\"noteClick\", \"sprites/noteClick.png\", {\n\t sliceX: 4,\n\t sliceY: 2,\n\t anims: {\n\t idle: {\n\t from: 7,\n\t to: 7,\n\t\t\t\t\t\t\tspeed: 30\n\t },\n\t click: {\n\t from: 0,\n\t to: 7,\n\t\t\t\t\t\t\tspeed: 60\n\t }\n\t },\n\t})\n\t// \n\t\n\t// Character\n\tloadSound(\"hitsoundFaithPlate\", \"sounds/hitsoundFaithPlate.mp3\");\n\tloadSound(\"hitsoundJellyBean\", \"sounds/hitsoundJellyBean.wav\");\n\tloadSound(\"hitsoundCarterRedacted\", \"sounds/hitsoundJellyBean.wav\");\n\tloadSound(\"hitsoundMarc\", \"sounds/hitsoundJellyBean.wav\");\n\tloadSound(\"hitsoundRedVelvety\", \"sounds/hitsoundRedVelvety.wav\");\n\tloadSound(\"hitsoundSonicAndTails\", \"sounds/hitsoundJellyBean.wav\");\n\tloadSound(\"hitsoundMarkyMark\", \"sounds/burp.mp3\");\n\tloadSprite(\"JellyBeanPre\", \"sprites/previews/JellyBeanPre.png\");\n\tloadSprite(\"RedVelvetyPre\", \"sprites/previews/RedVelvetyPre.png\");\n\tloadSprite(\"MarkyMarkPre\", \"sprites/previews/MarkyMarkPre.png\");\n\tloadSprite(\"CarterRedactedPre\", \"sprites/previews/CarterRedactedPre.png\");\n\tloadSprite(\"MarcPre\", \"sprites/previews/MarcPre.png\");\n\tloadSprite(\"FaithPlatePre\", \"sprites/previews/FaithPlatePre.png\");\n\tloadSprite(\"SonicAndTailsPre\", \"sprites/previews/SonicAndTailsPre.png\");\n\t// \n\t\n\t// Cake/tutorial\n\tloadSprite(\"tutorialBG0\", \"sprites/bgCake.png\");\n\tloadSprite(\"tutorialFG0\", \"sprites/fgCake0.png\");\n\tloadSprite(\"tutorialFG1\", \"sprites/fgCake1.png\");\n\tloadSprite(\"Marctutorial\", \"sprites/marcCake.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n\t to: 5,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 6,\n\t to: 8,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t})\n\tloadSprite(\"CarterRedactedtutorial\", \"sprites/carterredactedCake.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n\t to: 5,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 6,\n\t to: 8,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t})\n\tloadSprite(\"MarkyMarktutorial\", \"sprites/markymarkCake.png\", {\n\t sliceX: 3,\n\t sliceY: 4,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n\t to: 7,\n\t\t\t\t\t\t\tspeed: 40\n\t },\n\t miss: {\n\t from: 8,\n\t to: 10,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t})\n\tloadSprite(\"RedVelvetytutorial\", \"sprites/redvelvetyCake.png\", {\n\t sliceX: 3,\n\t sliceY: 4,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n\t to: 5,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t dox: {\n\t from: 6,\n\t to: 7,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 8,\n\t to: 10,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t})\n\tloadSprite(\"JellyBeantutorial\", \"sprites/jellybeanCake.png\", {\n\t sliceX: 3,\n\t sliceY: 4,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n \t\t to: 5,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t dox: {\n \tfrom: 6,\n \t to: 7,\n\t\t\t\t\t\t\tspeed: 20\n \t },\n \t miss: {\n \t from: 8,\n\t to: 10,\n\t\t\t\t\t\t\tspeed: 10\n \t \t },\n\t },\n\t})\n\t// \n\n\t// Faith/faith\n\tloadSprite(\"faithBG0\", \"sprites/bgFaith.png\");\n\tloadSprite(\"faithFG0\", \"sprites/fgFaith.png\");\n\tloadSprite(\"FaithPlatefaith\", \"sprites/faithplateFaith.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 3,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 4,\n\t to: 5,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 6,\n\t to: 8,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t})\n\t// \n\n\t// Sonic In Mid Sim/sonic\n\tloadSprite(\"sonicBG0\", \"sprites/SonicBG.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 6,\n\t\t\t\t\t\t\tspeed: 10,\n\t\t\t\t\t\t\tloop: true\n\t }\n\t },\n\t});\n\tloadSprite(\"sonicFG0\", \"sprites/SonicFG.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 0,\n\t\t\t\t\t\t\tspeed: 20\n\t }\n\t },\n\t});\n\tloadSprite(\"SonicAndTailssonic0\", \"sprites/SonicMidSim.png\", {\n\t sliceX: 3,\n\t sliceY: 4,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 6,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 7,\n\t to: 8,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 9,\n\t to: 11,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t});\n\tloadSprite(\"SonicAndTailssonic1\", \"sprites/TailsMidSim.png\", {\n\t sliceX: 3,\n\t sliceY: 9,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 15,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 16,\n\t to: 23,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 24,\n\t to: 26,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t});\n\tloadSprite(\"greenBG0\", \"sprites/SonicBG.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 6,\n\t\t\t\t\t\t\tspeed: 10,\n\t\t\t\t\t\t\tloop: true\n\t }\n\t },\n\t});\n\tloadSprite(\"greenFG0\", \"sprites/SonicFG.png\", {\n\t sliceX: 3,\n\t sliceY: 3,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 0,\n\t\t\t\t\t\t\tspeed: 20\n\t }\n\t },\n\t});\n\tloadSprite(\"SonicAndTailsgreen0\", \"sprites/SonicMidSim.png\", {\n\t sliceX: 3,\n\t sliceY: 4,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 6,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 7,\n\t to: 8,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 9,\n\t to: 11,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t});\n\tloadSprite(\"SonicAndTailsgreen1\", \"sprites/TailsMidSim.png\", {\n\t sliceX: 3,\n\t sliceY: 9,\n\t anims: {\n\t idle: {\n\t from: 0,\n\t to: 15,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t talk: {\n\t from: 16,\n\t to: 23,\n\t\t\t\t\t\t\tspeed: 20\n\t },\n\t miss: {\n\t from: 24,\n\t to: 26,\n\t\t\t\t\t\t\tspeed: 10\n\t },\n\t },\n\t});\n\t\n\tresolve(\"All assets loaded.\");\n}))\n\nvar charts = {\n\t\"tutorial\": [\n\t\t5, // How much seconds it takes to get from Right Stage to the hitmarker\n\t\t135, // Song BPM\n\t\t\"................................................................................................................................J...........J.J...........J.J.J.............J.J.................J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J.............J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J.............J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J...J...J.J...J...........J.J...........J.J...J...............................J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J...................................J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.....J.............................J.J.J.J.J.J.J.J.J.J.J.J.J.J.J...................................J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.....J.J.....J.J.....J...........J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.................................J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.....J.J.....J.J.....J.J.....J...................................................................................................................................J...........J.J...........J.J.J.............J.J...J...J...J.J...J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J...J...J.J...J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J...J...J.J...J...........J.J...........J.J...J...............................J...........J.J...........J.J.J.............J.J...J...J...J.J...J...........J.J...........J.J...J...............................................................................................................................................................................................................................................................\",\n\t\t1 //Texture Scale (too lazy to upsize sprites sometimes)\n\t],\n\t\"faith\": [\n\t\t2, \n\t\t120, \n\t\t\"................................................................................................................................J...J...J...JJJJJ...J...J...J...J.J.J.J.J.J.J.J.JJJJJJJJJ.J.J.JJJ.J.J.J.J.J.JJJJJ.JJJ.J.J.J.J.J.J.JJJ.JJJ.J.J.J.JJJJJJJJJJJJJJJJJ.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.JJJ.JJJ.JJJ.JJJ.JJJ.J.J.J.J.JJJ.J.JJJJJJJJJJJJJ.J.J.J.JJJJJ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.J.JJJ.J.JJJJ........JJJ.JJJ.JJJ.JJJJJ.J.JJJJJ.......JJJ.J.............\",\n\t\t4\n\t],\n\t\"sonic\": [\n\t\t2, \n\t\t139, \n\t\t\"..................................................J.J.J.J.J.JJ....J.J.J.J..J........JJJJ..J.JJ.J..................T.T.T.T.T.TT....T...T.T..T........TTT.T.T.TT.T..................J.J.J.J.J.J.J.J.J...J...........J.J.J.J.J.JJ..J.................T.T.T.T.T.T.T.T.T...T...........T.T.T.T.T.TT..T...............J.....J.....J.J.J.JJ....T.TT........J.J.J.J.J.J.J.J...J.........T.....T.....T.T.T.TT....J.JJ....DD.D.............................................................\",\n\t\t1\n\t],\n\t\"green\": [\n\t\t2, \n\t\t150, \n\t\t\"................J.....J.....J.....J.....J...J...J.....J.....J...................J.....J.....J...J.....J.....J...J.....J.................................T.T...T.T...T.T...T...........T.T.T...T.T...T.T...T.............T.T...T.T...T.T...T...........T.T.T...T.T...T.T...T.....T.......J.J...J.J...D.J.T.J.T...T.....J.J.J...J.J...D.J.T.J.T...T.......J.J...J.J...D.J.T.J.T...T.....J.J.J...J.J...D.J.T.J.D...D.....J.....J.....J.....J.T.D.T.J.....J.....J.....J.....J.T.D.T.J.....J.....J.....J.....J.T.D.T.J.T.T.T...T.T.T...T.T.T.T.T.T.T.........J.J...J.J...J.J...J...........J.J.J...J.J...J.J...J.............J.J...J.J...J.J...J...........J.J.J...J.J...J.J...J.....J.......T.T...T.T...D.T.J.T.J...J.....T.T.T...T.T...D.T.J.T.J...J.......T.T...T.T...D.T.J.T.J...J.....T.T.T...T.T...D.T.J.T.J.T.D.....T.....T.....T.....T.J.D.J.T.....T.....T.....T.....T.J.D.J.T.....T.....T.....T.....T.J.D.J.T.J.J.J...J.J.J...J.J.J.J.J.J.J................................................................................................................................................................\",\n\t\t1\n\t]\n};\nvar songIdx = 0;\nvar idx = 0;\n\nscene(\"Game\", (arr) => {\n\tvar song = arr[0]; //Also Chart access\n\tvar char = arr[1];\n\tvar hitsound = \"hitsound\" + arr[1];\n\tvar chart = charts[song];\n\tvar crochet = ((60 / chart[1]) * 1000);\n\tvar board = width() - strumLine;\n\tvar curBeat;\n\tvar curStep;\n\tvar autoplay = false;\n\tvar debugMode = false;\n\tvar score = 0;\n\tvar combo = 0;\n\tvar health = 1;\n\tvar font = \"apl386o\";\n\tif (char == \"MarkyMark\") {\n\t\tfont = \"unscii\";\n\t}\n\tvar strumLine = width() / 2;\n\tconst music = play(song, {\n\t volume: 1,\n\t loop: false\n\t});\n\tconst underlay = play(\"score\", {\n\t volume: 1,\n\t loop: false\n\t});\n\tmusic.pause()\n\twait(chart[0], () => {\n\t\tunderlay.pause();\n\t\tmusic.play();\n\t\tunderlay.play(music.time() + chart[0]);\n\t});\n\tlayers([\n \"bg\",\n\t\t\"JELLYBEAN\",\n \"SKELETONS\",\n\t\t\"fg\",\n \"ui0\",\n\t\t\"ui1\"\n\t], \"ui0\");\n\tvar player;\n\tvar player2;\n\tif (song == \"sonic\" || song == \"green\") {\n\t\tplayer = add([\n\t sprite(char + song + \"0\"),\n\t\t\tlayer(\"JELLYBEAN\"),\n\t\t\t\"dances\",\n\t\t\tpos(20, 108),\n\t\t\tscale(chart[3])\n\t\t])\n\t\tplayer2 = add([\n\t sprite(char + song + \"1\"),\n\t\t\tlayer(\"JELLYBEAN\"),\n\t\t\t\"dances\",\n\t\t\tpos(224, 20),\n\t\t\tscale(chart[3])\n\t\t])\n\t} else {\n\t\tplayer = add([\n\t sprite(char + song),\n\t\t\tlayer(\"JELLYBEAN\"),\n\t\t\t\"dances\",\n\t\t\t(song == \"faith\" ? pos(0, 0) : pos((width() / 2) - 162, height() - 400)),\n\t\t\tscale(chart[3])\n\t\t])\n\t}\n\tconst bg = add([\n\t\tsprite(song + \"BG0\"),\n\t\tlayer(\"bg\"),\n\t\tscale(chart[3])\n\t])\n\tif(song == \"sonic\" || song == \"green\") bg.play(\"idle\");\n\tconst fg = add([\n\t\tsprite(song + \"FG0\"),\n\t\t(song == \"faith\" ? layer(\"bg\") : layer(\"fg\")),\n\t\tscale(chart[3])\n\t])\n\tif (song == \"tutorial\") {\n\tconst fg = add([\n\t\tsprite(song + \"FG1\"),\n\t\tlayer(\"fg\"),\n\t\tscale(chart[3])\n\t]);\n\t}\n\tconst noteClick = add([\n\t\tsprite(\"noteClick\"),\n\t\tscale(0.25),\n\t\tpos(strumLine, 15)\n\t])\n\tonUpdate(() => {\n\t\tif (health > 1) health = 1;\n\t\tif (health < 0) {health = 0;go(\"Lose\", score);music.stop();}\n\t\tif (music.time() > music.duration() && health >= 0) {go(\"Title\");}\n\t\tstrumLine = lerp(18, width() / 2, health);\n\t\tnoteClick.pos.x = strumLine - 5;\n\t\tcurBeat = Math.floor(((music.time() * 1000) / crochet) * 10) / 10;\n\t\tcurStep = Math.floor((music.time() * 1000) / (crochet / 4));\n\t\tprevBeat = Math.floor(((underlay.time() * 1000) / crochet));\n\t\tprevStep = Math.floor((underlay.time() * 1000) / (crochet / 4));\n\t\tif (!get(\"bar\" + prevBeat).length) {\n\t\t\tvar bar = add([\n\t\t\t\tprevBeat % 4 == 0 ? rect(3, 50) : rect(2, 50),\n\t\t\t\tpos(width(), 20),\n\t\t\t\tcolor(255, 255, 255),\n\t\t\t\t(\"bar\" + prevBeat),\n\t\t\t\t{\n\t\t\t\t\tmainBar: prevBeat % 4 == 0,\n\t\t\t\t\tcreated: underlay.time()\n\t\t\t\t},\n\t\t\t\t\"bar\"\n\t\t\t]);\n\t\t}\n\t\tif (!get(\"note\" + prevStep).length) {\n\t\t\tmakeNote(chart[2][Math.floor(prevStep)]);\n\t\t}\n\t\tif (!underlay.isPaused()) {\n\t\t\tevery(\"bar\", (j) => {\n\t\t\t\tj.pos.x = lerp(width(), strumLine, (underlay.time() - j.created) / chart[0]);\n\t\t\t\tif(j.pos.x <= strumLine) {\n\t\t\t\t\tbeatHit();\n\t\t\t\t\tif (debugMode) play(\"metro\", {detune: j.mainBar ? 200 : 0});\n\t\t\t\t\tdestroy(j);\n\t\t\t\t}\n\t\t\t});\n\t\t\tevery(\"note\", (j) => {\n\t\t\t\tj.pos.x = lerp(width(), strumLine, (underlay.time() - j.created) / chart[0]);\n\t\t\t\tif(autoplay) {\n\t\t\t\t\tif(j.pos.x <= strumLine && !j.empty) {\n\t\t\t\t\t\tplay(hitsound);\n\t\t\t\t\t player.play(\"talk\");\n\t\t\t\t\t\tdestroy(j);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif(j.pos.x <= strumLine - 20 && !j.empty) {\n\t\t\t\t\t\tscore -= 200;\n\t\t\t\t\t\tdestroy(j);\n\t\t\t\t\t\tplay(\"explode\");\n\t\t\t\t\t\tplayer.play(\"miss\");\n\t\t\t\t\t\tshake(5);\n\t\t\t\t\t\tcombo = 0;\n\t\t\t\t\t\thealth -= 0.1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j.pos.x >= strumLine - 20 && j.empty) {\n\t\t\t\t\tif(j.pos.x <= strumLine) {\n\t\t\t\t\t\tdestroy(j); //Destroys note. No score.\n\t\t\t\t\t\tplayer2?.play(\"talk\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t})\n\tvar mt;\n\tonKeyPress(\"enter\", () => {\n\t\tif (!underlay.isPaused()) {\n\t\t\tunderlay.pause();\n\t\t\tmusic.pause();\n\t\t\tmt = [underlay.time(), music.time()];\n\t\t} else {\n\t\t\tunderlay.play(mt[0]);\n\t\t\tmusic.play(mt[1]);\n\t\t}\n\t});\n\tonKeyPress(\"space\", () => {judgeHitsLol()});\n\tonKeyPress(\"a\", () => {autoplay = !autoplay});\n\tonKeyPress(\"d\", () => {debugMode = !debugMode});\n\tonClick(() => {judgeHitsLol()});\n\tonTouchStart(() => {judgeHitsLol()});\n\tonDraw(() => {\n\t\tdrawLine({\n \tp1: vec2(0, 20),\n \tp2: vec2(width(), 20),\n \t width: 2,\n\t color: rgb(255, 255, 255),\n\t\t})\n\t\tdrawLine({\n \tp1: vec2(0, 70),\n \tp2: vec2(width(), 70),\n \t width: 2,\n\t color: rgb(255, 255, 255),\n\t\t})\n\t\tdrawLines({ // 80 * 240, 20 * 60\n \tpts: [ vec2(strumLine, 18), vec2(strumLine + 10, 18), vec2(strumLine + 10, 72), vec2(strumLine, 72), vec2(strumLine, 18) ],\n \twidth: 2,\n \t pos: vec2(100, 200),\n\t color: rgb(255, 255, 255),\n\t\t})\n drawText({\n \t text: \"MID-SIMULATOR DEMO -- WORK IN PROGRESS!\",\n \tsize: 20,\n \t pos: vec2(0, 0),\n\t\t\tfont: font\n\t\t});\n\t\tif (debugMode) {\n drawText({\n \t text: underlay.time() * 1000,\n \tsize: 20,\n \t pos: vec2(0, 20),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: curBeat,\n \tsize: 20,\n \t pos: vec2(0, 40),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: prevStep + \"/\" + (chart[2].length - 1),\n \tsize: 20,\n \t pos: vec2(0, 60),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: (chart[2][Math.floor(prevStep)] ? chart[2][Math.floor(prevStep)] : \".\"),\n \tsize: 20,\n \t pos: vec2(0, 80),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: (chart[2][Math.floor(curStep)] ? chart[2][Math.floor(curStep)] : \".\"),\n \tsize: 20,\n \t pos: vec2(0, 100),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: \"Health: \" + health,\n \tsize: 20,\n \t pos: vec2(strumLine, 120),\n\t\t\tfont: font\n\t\t});\n\t\t}\n drawText({\n \t text: \"Score: \" + score,\n \tsize: 20,\n \t pos: vec2(strumLine, 80),\n\t\t\tfont: font\n\t\t});\n drawText({\n \t text: \"Combo: \" + combo,\n \tsize: 20,\n \t pos: vec2(strumLine, 100),\n\t\t\tfont: font\n\t\t});\n\t\tif (autoplay) {\n\t\t\tdrawText({\n\t \t text: \"AUTOPLAY\",\n\t \tsize: 20,\n \t\t pos: vec2(strumLine, 120),\n\t\t\t\tfont: font\n\t\t\t});\n\t\t}\n\t})\n\tfunction makeNote(letter) {\n\t\tswitch (letter) {\n\t\t\tcase \"J\":\n\t\t\t\tadd([\n\t\t\t\t\t\trect(10, 50),\n\t\t\t\t\t\tpos(width(), 20),\n\t\t\t\t\t\tchart[2][Math.floor(prevStep)] == \"F\" ? color(168, 56, 50) : color(232, 3, 252),\n\t\t\t\t\t\t(\"note\" + prevStep),\n\t\t\t\t\t\t\"note\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcreated: underlay.time(),\n\t\t\t\t\t\t\ttype: chart[2][Math.floor(prevStep)]\n\t\t\t\t\t\t}\n\t\t\t\t]);\n\t\t\t\tbreak;\n\t\t\tcase \"T\":\n\t\t\t\tadd([\n\t\t\t\t\t\trect(0, 50),\n\t\t\t\t\t\tpos(width(), 20),\n\t\t\t\t\t\t(\"note\" + prevStep),\n\t\t\t\t\t\t\"note\",\n\t\t\t\t\t\t\"empty\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcreated: underlay.time(),\n\t\t\t\t\t\t\tempty: true,\n\t\t\t\t\t\t\ttype: chart[2][Math.floor(prevStep)]\n\t\t\t\t\t\t}\n\t\t\t\t]);\n\t\t\t\tbreak;\n\t\t\tcase \"D\":\n\t\t\t\tadd([\n\t\t\t\t\t\trect(10, 50),\n\t\t\t\t\t\tpos(width(), 20),\n\t\t\t\t\t\tchart[2][Math.floor(prevStep)] == \"F\" ? color(168, 56, 50) : color(232, 3, 252),\n\t\t\t\t\t\t(\"note\" + prevStep),\n\t\t\t\t\t\t\"note\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcreated: underlay.time(),\n\t\t\t\t\t\t\ttype: chart[2][Math.floor(prevStep)]\n\t\t\t\t\t\t}\n\t\t\t\t]);\n\t\t\t\tadd([\n\t\t\t\t\t\trect(0, 50),\n\t\t\t\t\t\tpos(width(), 20),\n\t\t\t\t\t\t(\"note\" + prevStep),\n\t\t\t\t\t\t\"note\",\n\t\t\t\t\t\t\"empty\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcreated: underlay.time(),\n\t\t\t\t\t\t\tempty: true,\n\t\t\t\t\t\t\ttype: chart[2][Math.floor(prevStep)]\n\t\t\t\t\t\t}\n\t\t\t\t]);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tfunction judgeHitsLol() {\n\t\tvar iv = false;\n\t\tevery(\"note\", (j) => {\n\t\t\tif (!iv) {\n\t\t\t\tif (!j.empty) {\n\t\t\t\t\tvar str = \"No Rating\";\n\t\t\t\t\tvar theColor = WHITE;\n\t\t\t\t\tif(j.pos.x >= strumLine - 20) {\n\t\t\t\t\t\tif(j.pos.x <= strumLine + 22) {\n\t\t\t\t\t\t\tiv = true;\n\t\t\t\t\t\t\tdestroy(j); //Destroys note. No score.\n\t\t\t\t\t\t\tnoteClick.play(\"click\");\n\t\t\t\t\t\t\tcombo += 1;\n\t\t\t\t\t\t\tstr = \"MID\";\n\t\t\t\t\t\t\ttheColor = RED;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(j.pos.x <= strumLine + 12) {\n\t\t\t\t\t\t\tplay(hitsound); //Plays sound!\n\t\t\t\t\t\t\tplayer.play(\"talk\");\n\t\t\t\t\t\t\tscore += 20;\n\t\t\t\t\t\t\thealth += 0.01;\n\t\t\t\t\t\t\tstr = \"Perfect!\";\n\t\t\t\t\t\t\ttheColor = MAGENTA;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(j.pos.x <= strumLine) {\n\t\t\t\t\t\t\tscore += 50;\n\t\t\t\t\t\t\thealth += 0.02;\n\t\t\t\t\t\t\tstr = \"Marvelous!\";\n\t\t\t\t\t\t\ttheColor = YELLOW;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(j.pos.x <= strumLine - 3) {\n\t\t\t\t\t\t\tscore += 50;\n\t\t\t\t\t\t\thealth -= 0.01;\n\t\t\t\t\t\t\tstr = \"Perfect!\";\n\t\t\t\t\t\t\ttheColor = MAGENTA;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(j.pos.x <= strumLine - 8) {\n\t\t\t\t\t\t\tscore -= 100;\n\t\t\t\t\t\t\thealth -= 0.02;\n\t\t\t\t\t\t\tstr = \"Overshot\";\n\t\t\t\t\t\t\ttheColor = CYAN;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (str != \"No Rating\") {\n\t\t\t\t\t\tvar origpos = strumLine - 16;\n\t\t\t\t\t\tvar ratingtxt = add([\n\t\t\t\t\t\t\ttext(str, {\n \t\t\t\tsize: 30, // 48 pixels tall\n \t\t\t\t\t\t}),\n\t\t\t\t\t\t\tpos(origpos, 48),\n\t\t\t\t\t\t\tcolor(theColor),\n\t\t\t\t\t\t\torigin(\"right\")\n\t\t\t\t\t\t]);\n\t\t\t\t\t\ttween(ratingtxt.pos, [\"y\"], 5, 48, 300, easings.easeOutSine, tweentypes.NORMAL);\n\t\t\t\t\t\ttween(ratingtxt, [\"opacity\"], 5, 1, 0, easings.easeOutSine, tweentypes.NORMAL, function() {\n\t\t\t\t\t\t\tdestroy(ratingtxt);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tfunction beatHit() {\n\t\tevery(\"dances\", (obj) => {\n\t\t\tif (player.curAnim() != \"talk\" && player.curAnim() != \"miss\") {\n\t\t\t\tobj.play(\"idle\");\n\t\t\t}\t\n\t\t});\n\t}\n});\n\nscene(\"Help\", () => {\n\tvar songs = [\n\t\t\"tutorial\",\n\t\t\"faith\",\n\t\t\"green\",\n\t\t\"sonic\"\n\t];\n\tvar names = [\n\t\t\"Tutorial\",\n\t\t\"Friendly Faith Plate\",\n\t\t\"Green Hill Zone\",\n\t\t\"Emerald Hill Zone\"\n\t]\n\tvar chars = {\n\t\ttutorial: [\n\t\t\t\"JellyBean\",\n\t\t\t\"RedVelvety\",\n\t\t\t\"Marc\",\n\t\t\t\"CarterRedacted\",\n\t\t\t\"MarkyMark\"\n\t\t],\n\t\tfaith: [\n\t\t\t\"FaithPlate\"\n\t\t],\n\t\tgreen: [\n\t\t\t\"SonicAndTails\"\n\t\t],\n\t\tsonic: [\n\t\t\t\"SonicAndTails\"\n\t\t]\n\t}\n\tconst bg = add([\n sprite(\"bgCake\")\n\t]);\n\tonDraw(() => {\n drawText({\n \t text: \"CONTROLS\",\n \tsize: 30,\n \t pos: vec2(25, 25)\n\t\t});\n drawText({\n \t text: \": ENABLE AUTOPLAY - ENTER TO PAUSE\",\n \tsize: 30,\n \t pos: vec2(60, 60)\n\t\t});\n drawText({\n \t text: \" / : HIT NOTE\",\n \tsize: 30,\n \t pos: vec2(55, 95)\n\t\t});\n\t\tdrawSprite({\n \t sprite: \"keyA\",\n\t\t\twidth: 60,\n\t\t\theight: 60,\n \t pos: vec2(5, 45)\n\t\t})\n\t\tdrawSprite({\n \t sprite: \"keySpace\",\n\t\t\twidth: 60,\n\t\t\theight: 60,\n \t pos: vec2(20, 80)\n\t\t})\n\t\tdrawSprite({\n \t sprite: \"keyClick\",\n\t\t\twidth: 60,\n\t\t\theight: 60,\n \t pos: vec2(95, 80)\n\t\t})\n drawText({\n \t text: \"SOUND & SHAKING WARNINGS\",\n \tsize: 30,\n \t pos: vec2(width() / 2 - 105, 25)\n\t\t});\n drawText({\n \t text: \"CHARACTER (\"+ (idx + 1) +\"/\"+ chars[songs[songIdx]].length +\"): \" + chars[songs[songIdx]][idx],\n \tsize: 30,\n \t pos: vec2(width() / 2, 200),\n\t\t\torigin: \"top\"\n\t\t});\n drawText({\n \t text: \"SONG (\"+ (songIdx + 1) +\"/\"+ songs.length +\"): \" + names[songIdx].toUpperCase(),\n \tsize: 30,\n \t pos: vec2(width() / 2, 160),\n\t\t\torigin: \"top\"\n\t\t});\n\t\tdrawSprite({\n \t sprite: chars[songs[songIdx]][idx] + \"Pre\",\n\t\t\twidth: 64,\n\t\t\theight: 64,\n \t pos: vec2((width() / 2) - 34, 248)\n\t\t});\n\t})\n\tadd([\n pos(0, 140),\n rect(700, 200),\n\t\tcolor(0, 0, 0)\n\t])\n\tvar lt = add([\n pos(10, 200),\n text(\"<\", {\n size: 30\n }),\n\t\tarea(),\n\t\t\"LeftText\"\n\t])\n\tvar rt = add([\n pos(width() - 30, 200),\n text(\">\", {\n size: 30\n }),\n\t\tarea(),\n\t\t\"RightText\"\n\t])\n\tvar dt = add([\n pos(10, 160),\n text(\"v\", {\n size: 30\n }),\n\t\tarea(),\n\t\t\"DownText\"\n\t])\n\tvar ut = add([\n pos(width() - 30, 160),\n text(\"^\", {\n size: 30\n }),\n\t\tarea(),\n\t\t\"UpText\"\n\t])\n\tvar clickText = add([\n pos(25, height() - 60),\n text(\"Press Space or Click Here to start\", {\n size: 30\n }),\n\t\tarea(),\n\t\t\"TEXT TEXT\"\n\t])\n\tfunction changeIdx(amt) {\n\t\tidx += amt;\n\t\tif (idx < 0) {\n\t\t\tidx = chars[songs[songIdx]].length - 1;\n\t\t} else if (idx >= chars[songs[songIdx]].length) {\n\t\t\tidx = 0;\n\t\t}\n\t}\n\tfunction changeSongIdx(amt) {\n\t\tsongIdx += amt;\n\t\tidx = 0;\n\t\tif (songIdx < 0) {\n\t\t\tsongIdx = songs.length - 1;\n\t\t} else if (songIdx >= songs.length) {\n\t\t\tsongIdx = 0;\n\t\t}\n\t}\n\t\n\tonKeyPress(\"left\", () => {changeIdx(-1)});\n\tonKeyPress(\"right\", () => {changeIdx(1)});\n\tonKeyPress(\"down\", () => {changeSongIdx(1)});\n\tonKeyPress(\"up\", () => {changeSongIdx(-1)});\n\tonKeyPress(\"`\", () => {go(\"Chart\", songs[songIdx])});\n\tonClick(\"LeftText\", () => {changeIdx(-1)});\n\tonClick(\"RightText\", () => {changeIdx(1)});\n\tonClick(\"DownText\", () => {changeSongIdx(1)});\n\tonClick(\"UpText\", () => {changeSongIdx(-1)});\n\tonKeyPress(\"space\", () => {go(\"Game\", [songs[songIdx], chars[songs[songIdx]][idx]]);/*losemus.stop();*/});\n\tonClick(\"TEXT TEXT\", () => {go(\"Game\", [songs[songIdx], chars[songs[songIdx]][idx]]);/*losemus.stop();*/});\n});\n\nscene(\"Title\", () => {\n\tconst bg = add([\n sprite(\"bgCake\")\n\t]);\n\tconst jb = add([\n sprite(\"jellybeanTitle\"),\n\t\tpos(0, height() - 320)\n\t]);\n\tconst logo = add([\n sprite(\"logo\"),\n\t\tpos(0, 0),\n\t\tscale(0.5, 0.5)\n\t]);\n\tonDraw(() => {\n drawText({\n \t text: \"SPACE/CLICK TO START\",\n \tsize: 30,\n \t pos: vec2(width() / 2 - 90, height() - 60)\n\t\t});\n\t})\n\tonKeyPress(\"space\", () => {go(\"Help\", [\"tutorial\"]);/*losemus.stop();*/});\n\tonClick(() => {go(\"Help\", [\"tutorial\"]);/*losemus.stop();*/});\n\tonTouchStart(() => {go(\"Help\", [\"tutorial\"]);/*losemus.stop();*/});\n});\n\nscene(\"Lose\", (score) => {\n\tconst lost = add([\n sprite(\"jellybeanFail\"),\n\t\t\"dances\",\n\t\tpos((width() / 2) - 162, height() / 2 - 162)\n\t])\n\tconst losemus = play(\"gameover\", {\n\t volume: 1,\n\t loop: true\n\t});\n\tonDraw(() => {\n drawText({\n \t text: \"YOU LOST LOL WHOOPS\",\n \tsize: 60,\n \t pos: vec2(0, height() - 120)\n\t\t});\n drawText({\n \t text: \"SPACE/CLICK TO RESTART\",\n \tsize: 30,\n \t pos: vec2(0, height() - 60)\n\t\t});\n drawText({\n \t text: \"SCORE: \" + score,\n \tsize: 30,\n \t pos: vec2(0, height() - 30)\n\t\t});\n\t})\n\tonKeyPress(\"space\", () => {go(\"Title\");losemus.stop();});\n\tonClick(() => {go(\"Title\");losemus.stop();});\n\tonTouchStart(() => {go(\"Title\");losemus.stop();});\n});\n\nscene(\"Chart\", (song) => {\n\tvar chart = charts[song];\n\tvar crochet = ((60 / chart[1]) * 1000);\n\tvar curBeat;\n\tvar curStep;\n\tvar songTime = 0;\n\tvar tool = \"J\";\n\tconst music = play(song, {\n\t volume: 1,\n\t loop: false\n\t});\n\tmusic.pause()\n\t\n\tvar lastTargeted = 4;\n\tvar tempChart = Array.from(Array(Math.floor((music.duration() * 1000) / (crochet / 4))), () => \".\");\n\t// Incredibly redundant, sadly I don't care\n\tvar coords = [\n\t\twidth() * 0.1,\n\t\twidth() * 0.2,\n\t\twidth() * 0.3,\n\t\twidth() * 0.4,\n\t\twidth() * 0.5,\n\t\twidth() * 0.6,\n\t\twidth() * 0.7,\n\t\twidth() * 0.8,\n\t\twidth() * 0.9\n\t];\n\tvar theEmpty = add([\n pos(width() * 0.2, height() * 0.8),\n rect(60, 60),\n text(\".\", {\n size: 48, // 48 pixels tall\n\t\t\t\twidth: 60\n }),\n color(255, 255, 255),\n outline(4, WHITE),\n\t\torigin(\"center\"),\n area(),\n\t\t\"theEmpty\"\n\t]);\n\tvar theJ = add([\n pos(width() * 0.4, height() * 0.8),\n rect(60, 60),\n text(\"J\", {\n size: 48, // 48 pixels tall\n\t\t\t\twidth: 60\n }),\n color(255, 255, 255),\n outline(4, WHITE),\n\t\torigin(\"center\"),\n area(),\n\t\t\"theJ\"\n\t]);\n\tvar theP = add([\n pos(width() * 0.6, height() * 0.8),\n rect(60, 30),\n text(\"P\", {\n size: 24, // 48 pixels tall\n\t\t\t\twidth: 60\n }),\n color(255, 255, 255),\n outline(4, WHITE),\n\t\torigin(\"center\"),\n area(),\n\t\t\"theP\"\n\t]);\n\tvar theD = add([\n pos(width() * 0.6, height() * 0.8 + 30),\n rect(60, 30),\n text(\"D\", {\n size: 24, // 48 pixels tall\n\t\t\t\twidth: 60\n }),\n color(255, 255, 255),\n outline(4, WHITE),\n\t\torigin(\"center\"),\n area(),\n\t\t\"theD\"\n\t]);\n\tvar consoleButton = add([\n pos(width() * 0.8, height() * 0.8),\n rect(60, 60),\n text(\"EXPORT\", {\n size: 30, // 48 pixels tall\n }),\n color(255, 255, 255),\n outline(4, WHITE),\n\t\torigin(\"center\"),\n area(),\n\t\t\"consoleButton\"\n\t]);\n\tonClick(\"theEmpty\", (o) => {tool = \".\"})\n\tonClick(\"theJ\", (o) => {tool = \"J\"})\n\tonClick(\"theP\", (o) => {tool = \"P\"})\n\tonClick(\"theD\", (o) => {tool = \"D\"})\n\tonClick(\"consoleButton\", (o) => {console.log(tempChart.join(\"\"));})\n\tonUpdate(() => {\n\t\tcurBeat = Math.floor(((music.time() * 1000) / crochet) * 10) / 10;\n\t\tcurStep = Math.floor((music.time() * 1000) / (crochet / 4));\n\t\tif (mousePos().y >= height() * 0.4 && mousePos().y < (height() / 2) + 34) { // I shouldve used a Switch Case here :/\n\t\t\tif (mousePos().x < width() * 0.15) {\n\t\t\t\t// blk0\n\t\t\t\tlastTargeted = 0;\n\t\t\t} else if (mousePos().x < width() * 0.25) {\n\t\t\t\t// blk1\n\t\t\t\tlastTargeted = 1;\n\t\t\t} else if (mousePos().x < width() * 0.35) {\n\t\t\t\t// blk2\n\t\t\t\tlastTargeted = 2;\n\t\t\t} else if (mousePos().x < width() * 0.45) {\n\t\t\t\t// blk3\n\t\t\t\tlastTargeted = 3;\n\t\t\t} else if (mousePos().x < width() * 0.55) {\n\t\t\t\t// blk4\n\t\t\t\tlastTargeted = 4;\n\t\t\t} else if (mousePos().x < width() * 0.65) {\n\t\t\t\t// blk5\n\t\t\t\tlastTargeted = 5;\n\t\t\t} else if (mousePos().x < width() * 0.75) {\n\t\t\t\t// blk6\n\t\t\t\tlastTargeted = 6;\n\t\t\t} else if (mousePos().x < width() * 0.85) {\n\t\t\t\t// blk7\n\t\t\t\tlastTargeted = 7;\n\t\t\t} else if (mousePos().x < width()) {\n\t\t\t\t// blk8\n\t\t\t\tlastTargeted = 8;\n\t\t\t}\n\t\t}\n\t});\n\tonMouseDown(() => {\n\t\tif (mousePos().y >= height() * 0.4 && mousePos().y < (height() / 2) + 34) {\n\t\t\ttempChart[curStep + lastTargeted] = tool;\n\t\t}\n\t});\n\tonDraw(() => {\n drawText({\n \t text: songTime * 1000,\n \tsize: 20,\n \t pos: vec2(0, )\n\t\t});\n drawText({\n \t text: music.time() * 1000,\n \tsize: 20,\n \t pos: vec2(0, 20)\n\t\t});\n drawText({\n \t text: curBeat,\n \tsize: 20,\n \t pos: vec2(0, 40)\n\t\t});\n drawText({\n \t text: curStep + \"/\" + (tempChart.length - 1),\n \tsize: 20,\n \t pos: vec2(0, 60)\n\t\t});\n drawText({\n \t text: tool,\n \tsize: 50,\n \t pos: vec2(width() / 2, height() * 0.65),\n\t\t\torigin: \"center\"\n\t\t});\n\t\tdrawLine({\n \t p1: vec2(coords[lastTargeted] - 30, (height() / 2) + 30),\n \t p2: vec2(coords[lastTargeted] + 30, (height() / 2) + 30),\n \t width: 4,\n \t color: rgb(255, 0, 0),\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep] ? tempChart[curStep] : \"\",\n \t size: 30,\n \t pos: vec2(coords[0], height() / 2),\n\t\t\tcolor: curStep % 4 == 0 ? RED : MAGENTA,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 1] ? tempChart[curStep + 1] : \"\",\n \t size: 30,\n \t pos: vec2(coords[1], height() / 2),\n\t\t\tcolor: (curStep + 1) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 2] ? tempChart[curStep + 2] : \"\",\n \t size: 30,\n \t pos: vec2(coords[2], height() / 2),\n\t\t\tcolor: (curStep + 2) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 3] ? tempChart[curStep + 3] : \"\",\n \t size: 30,\n \t pos: vec2(coords[3], height() / 2),\n\t\t\tcolor: (curStep + 3) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 4] ? tempChart[curStep + 4] : \"\",\n \t size: 30,\n \t pos: vec2(coords[4], height() / 2),\n\t\t\tcolor: (curStep + 4) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 5] ? tempChart[curStep + 5] : \"\",\n \t size: 30,\n \t pos: vec2(coords[5], height() / 2),\n\t\t\tcolor: (curStep + 5) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 6] ? tempChart[curStep + 6] : \"\",\n \t size: 30,\n \t pos: vec2(coords[6], height() / 2),\n\t\t\tcolor: (curStep + 6) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 7] ? tempChart[curStep + 7] : \"\",\n \t size: 30,\n \t pos: vec2(coords[7], height() / 2),\n\t\t\tcolor: (curStep + 7) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t\tdrawText({\n \ttext: tempChart[curStep + 8] ? tempChart[curStep + 8] : \"\",\n \t size: 30,\n \t pos: vec2(coords[8], height() / 2),\n\t\t\tcolor: (curStep + 8) % 4 == 0 ? RED : WHITE,\n\t\t\torigin: \"center\"\n\t\t})\n\t});\n\n\tonKeyPress(\"left\", () => {\n\t\tmusic.pause();\n\t\tsongTime = songTime - ((crochet / 4) / 1000);\n\t\ttry {\n\t\t\tmusic.play(songTime);\n\t\t} catch (err) {\n\t\t\tconsole.log(err);\n\t\t\tsongTime = 0;\n\t\t\tmusic.play(0);\n\t\t}\n\t\tmusic.pause();\n\t});\n\tonKeyPress(\"right\", () => {\n\t\tmusic.pause();\n\t\tsongTime = songTime + ((crochet / 4) / 1000);\n\t\ttry {\n\t\t\tmusic.play(songTime);\n\t\t} catch (err) {\n\t\t\tconsole.log(err);\n\t\t\tsongTime = 0;\n\t\t\tmusic.play(0);\n\t\t}\n\t\tmusic.pause();\n\t});\n\tonKeyPress(\"space\", () => {\n\t\tif (!music.isPaused()) {\n\t\t\tmusic.pause();\n\t\t\tsongTime = music.time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