-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
76 lines (65 loc) · 1.97 KB
/
javascript.js
File metadata and controls
76 lines (65 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var power = 0;
var coinsPS = 0;
var coinsPC = 1;
var addInterval;
var coinsPScost = 20;
var unitType = "Electrons";
var PSValue = 1;
var upgradeCoinsPScost = 50;
var clickValue = 1;
var upgradeClickValueCost = 15;
function gainCoin()
{
power += Math.round(coinsPC * clickValue);
}
setInterval(function renderCoins()
{
document.getElementById("power").innerHTML = "Total Electricity: " + power + " " + unitType;
})
setInterval(function renderCoinsPScost()
{
document.getElementById("coinsPScost").innerHTML = "Magnet Cost: " + coinsPScost;
})
setInterval(function renderCoinsPS()
{
document.getElementById("coinsPS").innerHTML = unitType + " Generated per Second: " + Math.round(coinsPS * PSValue);
})
setInterval(function renderUpgradeCoinsPS()
{
document.getElementById("upgradeCoinsPScost").innerHTML = "Cost for upgrade: " + upgradeCoinsPScost;
})
setInterval(function renderUpgradeClickValue()
{
document.getElementById("upgradeClickValueCost").innerHTML = "Cost for click upgrade: " + upgradeClickValueCost;
})
function getCoinsPS()
{
if (power >= coinsPScost)
{
coinsPS += 1;
power -= coinsPScost;
coinsPScost = (coinsPScost*1.05) - (coinsPScost*1.05)%1;
}
}
addInterval = setInterval(function coinPS() //iteration of coins per second
{
power += Math.round(coinsPS * PSValue);
}, 1000)
function upgradeCoinsPS()
{
if(power >= upgradeCoinsPScost)
{
PSValue += 1;
power -= upgradeCoinsPScost;
upgradeCoinsPScost = (upgradeCoinsPScost * 1.175) - (upgradeCoinsPScost*1.175)%1;
}
}
function upgradeClickValue()
{
if(power >= upgradeClickValueCost)
{
power -= upgradeClickValueCost;
clickValue += 1 + ((clickValue * 0.175) - (clickValue * 0.175)%1);
upgradeClickValueCost = (upgradeClickValueCost*1.175) - (upgradeClickValueCost*1.175)%1;
}
}