CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
ProdigyPNP

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: ProdigyPNP/ProdigyMathGameHacking
Path: blob/master/cheatGUI/src/utils/wasd.ts
Views: 723
1
import { useWASD } from "../hacks/location";
2
import { player } from "./util";
3
4
5
6
async function ChangeX (x : number) {
7
for (let i = 0; i < 100; i++) {
8
await new Promise(r => setTimeout(r, 2));
9
player._playerContainer.x -= x/100;;
10
}
11
}
12
13
async function ChangeY (y : number) {
14
for (let i = 0; i < 100; i++) {
15
await new Promise(r => setTimeout(r, 2));
16
player._playerContainer.y -= y/100;;
17
}
18
}
19
20
21
22
23
24
window.addEventListener("keydown", event => {
25
26
if (useWASD) {
27
switch (event.key) {
28
case "w":
29
ChangeY(40);
30
break;
31
case "s":
32
ChangeY(-40);
33
break;
34
case "a":
35
ChangeX(40);
36
break;
37
case "d":
38
ChangeX(-40);
39
break;
40
}
41
}
42
43
});
44