proper economy, particle fixes
This commit is contained in:
parent
a455575a64
commit
e02b63f13f
5 changed files with 63 additions and 26 deletions
|
@ -58,7 +58,6 @@
|
|||
<canvas id="c" width="640" height="480"></canvas>
|
||||
<div class='hud'>
|
||||
<div class='main-hud'>hud</div>
|
||||
<button class='buy'>test</button>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -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;
|
||||
})
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
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();
|
||||
})
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue