-
Notifications
You must be signed in to change notification settings - Fork 9
/
antlia-interact.js
125 lines (121 loc) · 3.66 KB
/
antlia-interact.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ANTLIA by Geikha
// https://github.com/geikha/hydra-antlia
//Interact
//MOUSE
//const
window.mouseXOffset = -.0135
window.mouseYOffset = -.0253
//vars
window.click = 0;
window.clicks = 0;
window.altClick = 0;
window.altClicks = 0;
window.ctrlClick = 0;
window.ctrlClicks = 0;
window.shiftClick = 0;
window.shiftClicks = 0;
window.randClick = Math.random();
window.rangedRandClick = (min = 0, max = 1) => { return randClick * (max - min) + min };
//funcs
window.mouseX = () => ((-mouse.x / window.innerWidth) + .5 + mouseXOffset);
window.mouseY = () => ((-mouse.y / window.innerHeight) + .5 + mouseYOffset);
osc().constructor.prototype.followMouse = function () {
return this.scroll(mouseX, mouseY)
}
//adding Listeners
window.document.body.addEventListener('mousedown', function (e) {
click = 1;
clicks += 1;
if (e.altKey) {
altClick = 1;
altClicks += 1;
} else if (e.ctrlKey) {
ctrlClick = 1;
ctrlClicks += 1;
} else if (e.shiftKey) {
shiftClick = 1;
shiftClicks += 1;
}
randClick = Math.random();
}, true);
window.document.body.addEventListener('mouseup', function () {
click = 0;
altClick = 0;
ctrlClick = 0;
shiftClick = 0;
}, true);
//ARROW KEYS
//vars
window.key = { up: 0, down: 0, left: 0, right: 0, x: 0, y: 0, sensitivity: 0.02 };
window.keyIsDown = { up: false, down: false, left: false, right: false };
//funcs
window.incrementKeys = function () {
if (window.keyIsDown.up) { window.key.y += key.sensitivity }
if (window.keyIsDown.left) { window.key.x += key.sensitivity }
if (window.keyIsDown.right) { window.key.x -= key.sensitivity }
if (window.keyIsDown.down) { window.key.y -= key.sensitivity }
}
//adding Listeners
//triggers
window.document.body.addEventListener('keydown', event => {
switch (event.keyCode) {
case 38: //up
key.up = 1; break;
case 40: //down
key.down = 1; break;
case 37: //left
key.left = 1; break;
case 39: //right
key.right = 1; break;
}
});
window.document.body.addEventListener('keyup', event => {
switch (event.keyCode) {
case 38: //up
key.up = 0; break;
case 40: //down
key.down = 0; break;
case 37: //left
key.left = 0; break;
case 39: //right
key.right = 0; break;
}
});
//axis
window.document.body.addEventListener('keydown', event => {
switch (event.keyCode) {
case 38: //up
keyIsDown.up = true; break;
case 40: //down
keyIsDown.down = true; break;
case 37: //left
keyIsDown.left = true; break;
case 39: //right
keyIsDown.right = true; break;
}
});
window.document.body.addEventListener('keyup', event => {
switch (event.keyCode) {
case 38: //up
keyIsDown.up = false; break;
case 40: //down
keyIsDown.down = false; break;
case 37: //left
keyIsDown.left = false; break;
case 39: //right
keyIsDown.right = false; break;
}
});
window.keyControlInterval = false;
window.initKeyControl = function (cps = 30) {
if (keyControlInterval)
stopKeyControl();
window.keyControlInterval = setInterval(incrementKeys, Math.trunc(1000 / cps))
};
window.stopKeyControl = () => { clearInterval(keyControlInterval); keyControlInterval = false; };
//wheel
window.wheel = { y: 0, sensitivity: 0.02 };
window.onwheel = function (e) {
let sign = e.deltaY > 0 ? -1 : 1;
wheel.y += (sign * wheel.sensitivity);
}