Professional Documents
Culture Documents
Message
Message
Message
x);
const angle = (a, b) => Math.atan2(b.y - a.y, b.x - a.x);
const nearestEntityFrom = (list, location = Process.self) =>
Object.values(list)
.filter(e => e.x && e.y && e?.id !== location?.id)
.sort((a, b) => dist(a, location) - dist(b, location))[0];
const toRad = angle => (Math.PI / 180) * angle;
const toDeg = angle => (180 / Math.PI) * angle;
class Process {
static get self() {
return Player.list[socket.id];
}
static sendAngle(deg) {
Process.send('angle', deg);
window.mouseAngle = deg;
}
static speed(num) {
Process.send('mouseDistance', num || 0);
}
static hit(bool) {
Process.send('leftButton', bool);
}
static boost(bool) {
Process.send('rightButton', bool);
}
static chat(msg) {
Process.send('chatMessage', msg);
}
static pause() {
Process.send('pause', true);
}
return { x, y };
}
static predictPos(entity) {
let vel = Process.vel(entity);
// ----------Testing---------- //
setInterval(e => {
let mob = nearestEntityFrom(window.Mob.list);
let food = nearestEntityFrom(window.Food.list);
let enemy = nearestEntityFrom(window.Player.list);
return;
}
inputAttack(false);
Process.speed(1);
}
});