From e02b63f13ffbe28ade819020fd61f04ec7b9c2a2 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Wed, 5 Mar 2025 13:24:24 -0500 Subject: [PATCH] proper economy, particle fixes --- docs/index.html | 1 - docs/js/idle.js | 41 ++++++++++++++++++++++------------------- docs/js/index.js | 6 ++++-- docs/js/upgrade.js | 31 +++++++++++++++++++++++++++---- docs/main.css | 10 ++++++++++ 5 files changed, 63 insertions(+), 26 deletions(-) diff --git a/docs/index.html b/docs/index.html index eddc2bf..835a402 100644 --- a/docs/index.html +++ b/docs/index.html @@ -58,7 +58,6 @@
hud
-
diff --git a/docs/js/idle.js b/docs/js/idle.js index 62f0da0..49a6d4f 100644 --- a/docs/js/idle.js +++ b/docs/js/idle.js @@ -13,7 +13,7 @@ window.addEventListener('mousemove', (e) => { my = e.pageY; }); -window.addEventListener('click', (e) => { +document.querySelector('canvas').addEventListener('click', (e) => { let p1 = MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000); for (let cubieI in cubePos) { let cubie = cubePos[cubieI]; @@ -33,37 +33,40 @@ window.addEventListener('click', (e) => { setInterval(function () { nothingness += nGain + getBonus; - getBonus += 0.001 * cubePos.length; - getBonus *= 0.9; + getBonus += 0.0001 * cubePos.length; + getBonus *= 0.93; for (let a of cubePos) { - a[0] = a[0] * 0.95 + a[3] * 10; - a[1] = a[1] * 0.95 + a[4] * 10; + let f = (nGain + getBonus * 100 + 10) / (nothingness + 10); - let f = (nGain + 0.01) / (nothingness + 0.01); + f *= 50; + + if (f > 100) f = 100; + + a[0] = a[0] * 0.9 + a[3] * .4 * f; + a[1] = a[1] * 0.9 + a[4] * .4 * f; + + f /= Math.sqrt(a[0] * a[0] + a[1] * a[1]) / 0.3; + + if (f > 0.3) f = 0.3; let a3 = a[3], a4 = a[4]; - f /= Math.sqrt(a[0] * a[0] + a[1] * a[1]); - f *= 50000; - 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; - }1 + + let d = Math.sqrt(a[3] * a[3] + a[4] * a[4]) + + a[3] /= d / 2; + a[4] /= d / 2; + } }, 1000 / 60) -window.addEventListener('click', async (e) => { +document.querySelector('canvas').addEventListener('click', async (e) => { 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; + getBonus += 0.01; clicking = false; }) diff --git a/docs/js/index.js b/docs/js/index.js index ed4070c..9cd7050 100644 --- a/docs/js/index.js +++ b/docs/js/index.js @@ -113,7 +113,7 @@ function renderThing() { gl.uniformMatrix4fv(matBuffer, false, new Float32Array(MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000))); - hud.textContent = `${Math.floor(nothingness * 100) / 100} nothings; ${Math.floor((nGain + getBonus) * 60 * 100) / 100} nil/sec` + hud.textContent = `${Math.floor(nothingness * 100) / 100} nil; ${Math.floor((nGain + getBonus) * 60 * 100) / 100} nil/sec` gl.uniform1f(sizeBuffer, -Math.log(nothingness)); gl.uniform1f(distBuffer, 0.1 + 3 * nGain / (nGain + nothingness)); @@ -124,7 +124,9 @@ function renderThing() { var count = 6; gl.drawArrays(primitiveType, offset, count); - let sizes = 1000 / (cubePos.length+30); + let sizes = (nGain + 1) / (nothingness + 1) * 1000000 / (cubePos.length+30); + sizes = Math.pow(sizes,0.3); + if (sizes > 10) sizes = 10; positions = MDN.createCubeData(sizes, sizes, sizes); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); diff --git a/docs/js/upgrade.js b/docs/js/upgrade.js index 1be3b97..60fa443 100644 --- a/docs/js/upgrade.js +++ b/docs/js/upgrade.js @@ -1,7 +1,30 @@ -document.querySelector('.buy').addEventListener('click', () => { - if (nothingness < 10) return; - nothingness -= 10; +function addCube() { cubePos.push([Math.random() * 1000 - 500, Math.random() * 1000 - 500, Math.random() * 30 - 200, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ]) -}) \ No newline at end of file +} + +let upgrades = [ + { + 'name': 'Set', + 'price': 10, + 'exec': addCube + } +] + +let hud2 = document.querySelector('.hud'); + +for (let upgrade of upgrades) { + let button = document.createElement("div"); + button.classList.add('item'); + button.textContent = `Buy ${upgrade.name} for ${upgrade.price} nil` + hud2.appendChild(button); + + button.addEventListener('click', () => { + if (nothingness < upgrade.price) return; + nothingness -= upgrade.price; + upgrade.price *= 1.02; + button.textContent = `Buy ${upgrade.name} for ${upgrade.price} nil` + upgrade.exec(); + }) +} \ No newline at end of file diff --git a/docs/main.css b/docs/main.css index d805080..fe3da08 100644 --- a/docs/main.css +++ b/docs/main.css @@ -19,4 +19,14 @@ body, html { min-width: 200px; min-height: 50px; font-size: 32px; + + user-select: none; +} + +.item { + font-size: 0.6em; + + background: rgb(255, 255, 255); + padding: 5px; + width: 300px; } \ No newline at end of file