-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js.map
7 lines (7 loc) · 3.07 KB
/
main.js.map
1
2
3
4
5
6
7
{
"version": 3,
"sources": ["../src/main.ts"],
"sourcesContent": ["var canvas: HTMLCanvasElement;\nvar context: CanvasRenderingContext2D;\n\ninterface Point {\n x: number;\n y: number;\n}\n\n// game variables\nvar middle: Point;\nvar r = 100;\nvar r_pos = r;\nvar v_r = 100; // pixels per second\nvar hue = 0;\n\n// system variables\nvar last_tick_t = 0;\nvar width: number;\nvar height: number;\nvar plop = new Audio(\"plop.wav\");\n\nvar logo = new Image();\nlogo.src = \"logo.png\";\n\nfunction draw() {\n context.resetTransform();\n context.clearRect(0, 0, width, height);\n\n // select color\n context.fillStyle = `hsl(${hue}, 50%, 50%)`;\n\n // draw polygon/path\n context.translate(middle.x, middle.y);\n context.beginPath();\n context.moveTo(0, -r);\n context.lineTo(r_pos, -r_pos);\n context.lineTo(r, 0);\n context.lineTo(r_pos, r_pos);\n context.lineTo(0, r);\n context.lineTo(-r_pos, r_pos);\n context.lineTo(-r, 0);\n context.lineTo(-r_pos, -r_pos);\n context.fill();\n context.resetTransform();\n\n context.drawImage(logo, 50, 50);\n}\n\nfunction update(dt: number) {\n // radial position\n r_pos += v_r * dt;\n if (r_pos > 1.5 * r) {\n v_r = -v_r;\n r_pos = 1.5 * r;\n } else if (r_pos < 0.1 * r) {\n v_r = -v_r;\n r_pos = 0.1 * r;\n }\n // color\n hue = (hue + 1) % 360;\n}\n\nfunction loop(t_ms: number) {\n // calculate dt\n let dt = t_ms - last_tick_t;\n last_tick_t = t_ms;\n\n update(dt / 10000); // to seconds\n draw();\n\n window.requestAnimationFrame(loop);\n}\n\nfunction click(e: MouseEvent) {\n plop.play();\n}\n\nfunction main() {\n canvas = document.querySelector(\"#canvas\") as HTMLCanvasElement;\n context = canvas.getContext(\"2d\")!;\n canvas.addEventListener(\"click\", click);\n\n width = canvas.width;\n height = canvas.height;\n middle = { x: width / 2, y: height / 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