add unions

This commit is contained in:
biglyderv 2025-03-07 03:46:03 -05:00
parent ce6c859e9c
commit e832b8f630
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
3 changed files with 33 additions and 10 deletions

View file

@ -15,8 +15,11 @@ window.addEventListener('mousemove', (e) => {
}); });
document.querySelector('canvas').addEventListener('click', (e) => { document.querySelector('canvas').addEventListener('click', (e) => {
let p1 = MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000); let p1 = MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000)
for (let cubieI in cubePos) { for (let cubieI in cubePos) {
let bonus = 1 + counts.doNothing / (cubieI + 2);
let cubie = cubePos[cubieI]; let cubie = cubePos[cubieI];
let p2 = MDN.multiplyPoint(p1, [cubie[0], cubie[1], cubie[2], 0]); let p2 = MDN.multiplyPoint(p1, [cubie[0], cubie[1], cubie[2], 0]);
@ -27,7 +30,8 @@ document.querySelector('canvas').addEventListener('click', (e) => {
p2[1] += (my - height / 2) / height * 2; p2[1] += (my - height / 2) / height * 2;
let b = 1 / (Math.sqrt(p2[0] ** 2 + p2[1] ** 2) + .03); let b = 1 / (Math.sqrt(p2[0] ** 2 + p2[1] ** 2) + .03);
b = (b * b) * 0.0001; b = (b * b) * 0.0001
b *= bonus;
getBonus += b; getBonus += b;
} }
@ -38,11 +42,15 @@ setInterval(function () {
nGain = 0.003 + 0.003 * cubePos.length; nGain = 0.003 + 0.003 * cubePos.length;
getBonus *= 0.93; getBonus *= 0.93;
for (let a of cubePos) { for (let ab in cubePos) {
let f = (nGain + getBonus * 10000 + 10) / (nothingness + 10); let a = cubePos[ab];
let bonus = 1 + counts.doNothing / (ab + 2);
bonus = (bonus) ** 0.05;
let f = (nGain + getBonus * bonus * 10000 + 10) / (nothingness + 10);
let dist = Math.sqrt(a[0] ** 2 + a[1] ** 2) let dist = Math.sqrt(a[0] ** 2 + a[1] ** 2)
dist = (f*90 / dist) ** 0.1; dist = (f * 90 / dist) ** 0.1;
a[3] = a[3] * 0.9 + a[0] * (dist - 1); a[3] = a[3] * 0.9 + a[0] * (dist - 1);
a[4] = a[4] * 0.9 + a[1] * (dist - 1); a[4] = a[4] * 0.9 + a[1] * (dist - 1);
@ -50,9 +58,9 @@ setInterval(function () {
a[0] += a[3] * 0.01; a[0] += a[3] * 0.01;
a[1] += a[4] * 0.01; a[1] += a[4] * 0.01;
a[3] += Math.sin(f*0.1) * a[1]; a[3] += Math.sin(f * 0.1) * a[1];
a[4] += -Math.sin(f*0.1) * a[0]; a[4] += -Math.sin(f * 0.1) * a[0];
} }
}, 1000 / 60) }, 1000 / 60)

View file

@ -132,12 +132,17 @@ function renderThing() {
if (sizes > 10) sizes = 10; if (sizes > 10) sizes = 10;
if (sizes < 3) sizes = 3; if (sizes < 3) sizes = 3;
positions = MDN.createCubeData(1,1,1); positions = MDN.createCubeData(1, 1, 1);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
for (let cubie of cubePos) { for (let ii in cubePos) {
let cubie = cubePos[ii];
let vp = MDN.rotateYMatrix(Math.log(nothingness + 1) * cubie[2] / 10); let vp = MDN.rotateYMatrix(Math.log(nothingness + 1) * cubie[2] / 10);
vp = MDN.multiplyMatrices(MDN.scaleMatrix(sizes,sizes,sizes), vp)
let bonus = 1 + counts.doNothing / (ii + 2);
bonus = bonus ** (1 / 2);
vp = MDN.multiplyMatrices(MDN.scaleMatrix(sizes * bonus, sizes * bonus, sizes * bonus), vp)
vp = MDN.multiplyMatrices(MDN.translateMatrix(cubie[0], cubie[1], cubie[2]), vp) vp = MDN.multiplyMatrices(MDN.translateMatrix(cubie[0], cubie[1], cubie[2]), vp)
gl.uniformMatrix4fv(vpBuffer, false, new Float32Array(vp)); gl.uniformMatrix4fv(vpBuffer, false, new Float32Array(vp));

View file

@ -1,5 +1,9 @@
let exec = {}; let exec = {};
exec.doNothing = function() {
}
exec.addCube = function () { exec.addCube = function () {
cubePos.push([Math.random() * 1000 - 500, Math.random() * 1000 - 500, Math.random() * 30 - 200, 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 Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1
@ -11,6 +15,12 @@ upgrades = [
'price': 30, 'price': 30,
'exec': 'addCube', 'exec': 'addCube',
'desc': 'Clicks and waiting generate more nil' 'desc': 'Clicks and waiting generate more nil'
},
{
'name': 'Union',
'price': 1000,
'exec': 'doNothing',
'desc': 'Earlier-bought Sets are more powerful'
} }
]; ];