-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
33 lines (31 loc) · 1.25 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { DEFAULT_SHRINK_DEFINITION, defaultIsSpecialEntity, gravitify } from "../src/lib"; /* simple for quick development */
// import { gravitify } from "gravitify"; /* with `npm link && npm link gravitify` */
const canvas = document.querySelector("canvas") as HTMLCanvasElement;
const main = document.querySelector("main") as HTMLElement;
const mainHeading = document.querySelector("h1#main-heading");
(document.querySelector("button#a") as HTMLButtonElement).addEventListener("click", () => {
console.log("A-Blue");
if (mainHeading) mainHeading.textContent = "Hello, Blue Button!";
});
(document.querySelector("button#b") as HTMLButtonElement).addEventListener("click", () => {
console.log("B-Magenta");
if (mainHeading) mainHeading.textContent = "Hello, Magenta Button!";
});
(document.querySelector("button#c") as HTMLButtonElement).addEventListener("click", () => {
console.log("C-Green");
if (mainHeading) mainHeading.textContent = "Hello, Green Button!";
});
gravitify(
main, canvas,
["#super-specific", "button", "a"], defaultIsSpecialEntity, DEFAULT_SHRINK_DEFINITION,
{
gravity: {
x: 0.0,
y: 0.3
},
body: {
friction: 1,
restitution: 0.3
}
}
);