unibutton/common/util.js

16 lines
No EOL
351 B
JavaScript

import crypto from "../crypto.js";
function distF(ent, target) {
return ((ent.pos.x - target.pos.x) ** 2) + ((ent.pos.y - target.pos.y) ** 2)
}
function uuidv4() {
return "#000000-000000".replace(/[018]/g, c =>
(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
);
}
export {
distF,
uuidv4
}