30 lines
No EOL
835 B
JavaScript
30 lines
No EOL
835 B
JavaScript
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();
|
|
})
|
|
} |