nothing-simulator/docs/js/idle.js

70 lines
1.6 KiB
JavaScript
Raw Normal View History

2025-03-05 01:00:00 -05:00
var nothingness = 1, nGain = 0.003;
var getBonus = 0;
var mx = 0, my = 0;
2025-03-04 22:32:32 -05:00
let clicking = false;
var cubePos = [
];
2025-03-05 01:00:00 -05:00
window.addEventListener('mousemove', (e) => {
mx = e.pageX;
my = e.pageY;
});
window.addEventListener('click', (e) => {
let p1 = MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000);
for (let cubieI in cubePos) {
let cubie = cubePos[cubieI];
let p2 = MDN.multiplyPoint(p1, [cubie[0], cubie[1], cubie[2], 1]);
p2[0] /= width;
p2[1] /= height;
p2[0] += (mx - width / 2) / width * 2;
p2[1] -= (my - height / 2) / height * 2;
let b = 0.001 / (Math.sqrt(p2[0] ** 2 + p2[1] ** 2) + .003);
getBonus += b;
}
});
2025-03-04 22:32:32 -05:00
setInterval(function () {
2025-03-05 01:00:00 -05:00
nothingness += nGain + getBonus;
getBonus += 0.001 * cubePos.length;
getBonus *= 0.9;
2025-03-04 22:32:32 -05:00
for (let a of cubePos) {
2025-03-05 01:00:00 -05:00
a[0] = a[0] * 0.95 + a[3] * 10;
a[1] = a[1] * 0.95 + a[4] * 10;
2025-03-04 22:32:32 -05:00
let f = (nGain + 0.01) / (nothingness + 0.01);
let a3 = a[3], a4 = a[4];
f /= Math.sqrt(a[0] * a[0] + a[1] * a[1]);
2025-03-05 01:00:00 -05:00
f *= 50000;
2025-03-04 22:32:32 -05:00
if (f > 0.3) f = 0.3;
a[3] = Math.sin(f) * a4 + Math.cos(f) * a3;
a[4] = -Math.sin(f) * a3 + Math.cos(f) * a4;
2025-03-05 01:00:00 -05:00
}1
2025-03-04 22:32:32 -05:00
}, 1000 / 60)
2025-03-05 01:00:00 -05:00
window.addEventListener('click', async (e) => {
2025-03-04 22:32:32 -05:00
if (clicking) return;
clicking = true;
let oldNGain = nGain;
nGain += 0.05;
while (nGain > oldNGain) {
nGain -= 0.005;
await new Promise((res) => setTimeout(res, 1000 / 60))
}
nGain = oldNGain;
clicking = false;
2025-03-05 01:00:00 -05:00
})