nothing-simulator/docs/js/idle.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-03-04 22:32:32 -05:00
var nothingness = 1, nGain = 0.00001;
let clicking = false;
var cubePos = [
];
setInterval(function () {
nothingness += nGain;
for (let a of cubePos) {
a[0] += a[3] * 10;
a[1] += a[4] * 10;
let f = (nGain + 0.01) / (nothingness + 0.01);
a[0] *= 0.95
a[1] *= 0.95
let a3 = a[3], a4 = a[4];
f /= Math.sqrt(a[0] * a[0] + a[1] * a[1]);
f *= 100;
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;
}
}, 1000 / 60)
document.body.onclick = async function () {
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;
}
for (let i = 0; i < 100; i++) {
cubePos.push([Math.random() * 1000 - 500, Math.random() * 1000 - 500, Math.random() * 30 - 120,
Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1
])
}