-
Notifications
You must be signed in to change notification settings - Fork 1
/
clicky.js
157 lines (145 loc) · 3.84 KB
/
clicky.js
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
var score = 0;
var manual = 1;
var auto = 1;
var autocost = 2;
var perclickcost = 2;
var autofactor = 2;
var perclickfactor = 2;
var fuseleft = 30;
var bombactive = false;
var bombbonus = 16;
var bombcost = 8;
var bombupgradecost = 32;
var rank = 1;
var rankupgradecost = 32;
//var multiplier = 1;
function manualClick(){
score += manual;
updatescreen();
if (score >= 32) {
document.getElementById('upgbuttonrank').style.visibility="visible";
document.getElementById('upgbuttonrankbutton').style.visibility="visible";
}
}
function upgButtonRank(){
if (score >= rankupgradecost) {
score -= rankupgradecost;
rankupgradecost *= 5;
rank += 1;
//multiplier += .1;
updatescreen();
if (rank >= 2) {
document.getElementById('persecond').style.visibility="visible";
document.getElementById('autobutton').style.visibility="visible";
}
if (rank >= 3) {
document.getElementById('perclick').style.visibility="visible";
document.getElementById('perclickbutton').style.visibility="visible";
}
if (rank >= 4) {
document.getElementById('armbomb').style.visibility="visible";
document.getElementById('armbombbutton').style.visibility="visible";
}
if (rank >= 5) {
document.getElementById('bombupgrade').style.visibility="visible";
document.getElementById('bombupgradebutton').style.visibility="visible";
}
}
}
function buyAuto(){
if (score >= autocost) {
score -= autocost;
autocost *= autofactor;
autofactor += .8;
auto *= 2;
updatescreen();
}
}
function upgradeBomb(){
if (score >= bombupgradecost) {
score -= bombupgradecost;
bombupgradecost *= 2;
bombbonus *= 2;
updatescreen();
}
}
function buyPerClick(){
if (score >= perclickcost) {
score -= perclickcost;
perclickcost *= perclickfactor;
perclickfactor += .8;
manual *= 2;
updatescreen();
}
}
function armBomb(){
if (score >= bombcost) {
if (!bombactive) {
bombactive = true;
score -= bombcost;
updatescreen();
} else {
alert("Bomb currently active.")
}
}
}
function doSomething() {
score += auto;
if (bombactive === true) {
fuseleft -= 1;
if (fuseleft <= 0) {
bombgoesoff();
updatescreen();
}
}
updatescreen();
}
function bombgoesoff() {
score += bombbonus;
fuseleft = 30;
bombactive = false;
$( "bombtick" ).html("No bomb currently.");
updatescreen();
$(game).shake();
$(right).shake();
}
setInterval(doSomething, 1000);
function updatescreen(){
// score *= multiplier;
scored = float2int(score);
autod = float2int(auto);
manuald = float2int(manual);
autocostd = float2int(autocost);
perclickcostd = float2int(perclickcost);
bombupgradecostd = float2int(bombupgradecost);
bombcostd = float2int(bombcost);
bombbonusd = float2int(bombbonus);
rankupgradecostd = float2int(rankupgradecost);
fuseleftd = float2int(fuseleft);
$( "#ranK" ).html("Rank " + rank);
$( "#totalclicks" ).html(scored + " points");
$( "#persecond" ).html(autod + " per second (" + autocostd + ")");
$( "#perclick" ).html(manuald + " per click (" + perclickcostd + ")");
$( "#armbomb" ).html(bombcostd + " per bomb");
$( "#bombupgrade" ).html(bombbonusd + " per explosion (" + bombupgradecostd + ")");
$( "#upgbuttonrank" ).html("Upgrade your rank (" + rankupgradecostd + ")");
if (bombactive) {
$( "#bombtick" ).html(fuseleftd + "!");
}
if (score >= 32) {
document.getElementById('upgbuttonrank').style.visibility="visible";
document.getElementById('upgbuttonrankbutton').style.visibility="visible";
}
}
jQuery.fn.shake = function() {
this.each(function(i) {
$(this).css({ "position" : "relative" });
for (var x = 1; x <= 3; x++) {
$(this).animate({ left: -25 }, 10).animate({ left: 0 }, 50).animate({ left: 25 }, 10).animate({ left: 0 }, 50);
}
});
return this;
}
function float2int (value) {
return ~~value;
}