-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKclickerv.1.js
275 lines (243 loc) · 7.68 KB
/
Kclickerv.1.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
//1兆個検討を積み重ねればゲームクリア
let amountK =10000; //時短のため+10000にとりあえずしておく。公開の時は0に戻す
let p5 = 0; //+5機能をオフにする
let p100 =0;
let p1000 = 0;
let p10000 =0;
let p100000 =0;
let p1000000 =0;
let p10000000 =0;
let p100000000 =0;
let timerStringDOM; //タイマーの時間を表示する場所を覚えておく変数
let plusamountpersec =0; //1秒あたり自動で増える数を0にする
//countup.htmlのidを呼び出して定数に格納
const timer = document.getElementById('timer');
const start = document.getElementById("start");
//開始時間の変数をセット
let startTime;
//変数startTimeに現在の時間(Date.now())を入れる
startTime = Date.now();
console.log(startTime);
countUp(); //関数countUp()を呼び出す
//ここに記述したイベントは、htmlが完全に読み込まれた後から実行される。
window.onload = function(){
timerStringDOM = document.getElementById('timerString');
}
const plus1 = function(){
amountK = amountK +1 ; //1増やす
document.getElementById('amountK').
textContent=amountK;
}
const plus5 = function(){
if (p5 == 1){
amountK = amountK +5 ; //5増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus100 = function(){
if (p100 == 1){
amountK = amountK +100 ; //100増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus1000 = function(){
if (p1000 == 1){
amountK = amountK +1000 ; //1000増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus10000 = function(){
if (p10000 == 1){
amountK = amountK +10000 ; //10000増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus100000 = function(){
if (p100000 == 1){
amountK = amountK +100000 ; //100000増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus1000000 = function(){
if (p1000000 == 1){
amountK = amountK +1000000 ; //100万増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus10000000 = function(){
if (p10000000 == 1){
amountK = amountK +10000000 ; //1000万増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const plus100000000 = function(){
if (p100000000 == 1){
amountK = amountK +100000000 ; //1億増やす
document.getElementById('amountK').
textContent=amountK;
}
}
const addp5 = function(){
if (amountK > 20){
if(p5 ==0){
amountK = amountK -20; //20減らす
p5 = 1; //+5機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp100 = function(){
if (amountK > 500){
if(p100 ==0){
amountK = amountK - 500; //500減らす
p100 = 1; //+5機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp1000 = function(){
if (amountK > 5000){
if(p1000 ==0){
amountK = amountK - 5000; //5000減らす
p1000 = 1; //+1000機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp10000 = function(){
if (amountK > 100000){
if(p10000 ==0){
amountK = amountK - 100000; //100000減らす
p10000 = 1; //+1000機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp100000 = function(){
if (amountK > 1500000){
if(p100000 ==0){
amountK = amountK - 1500000; //150万減らす
p100000 = 1; //+10000機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp1000000 = function(){
if (amountK > 15000000){
if(p1000000 ==0){
amountK = amountK - 15000000; //1500万減らす
p1000000 = 1; //+100万機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp10000000 = function(){
if (amountK > 150000000){
if(p10000000 ==0){
amountK = amountK - 150000000; //1.5億減らす
p10000000 = 1; //+1000万機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const addp100000000 = function(){
if (amountK > 2000000000){
if(p100000000 ==0){
amountK = amountK - 2000000000; //20億減らす
p100000000 = 1; //+1億機能をオンにする
document.getElementById('amountK').
textContent=amountK;
}
}
}
const auto1 = function(){
if (amountK > 100){
amountK = amountK -100; //100減らす
document.getElementById('amountK').
textContent=amountK;
plusamountpersec = plusamountpersec + 1; //1秒で増える数を1増やす
document.getElementById('plusamountpersec').
textContent=plusamountpersec;
}
}
const auto10 = function(){
if (amountK > 950){
amountK = amountK - 950; //950減らす
document.getElementById('amountK').
textContent=amountK;
plusamountpersec = plusamountpersec + 10; //1秒で増える数を10増やす
document.getElementById('plusamountpersec').
textContent=plusamountpersec;
}
}
const auto100 = function(){
if (amountK > 9300){
amountK = amountK - 9300; //9300減らす
document.getElementById('amountK').
textContent=amountK;
plusamountpersec = plusamountpersec + 100; //1秒で増える数を100増やす
document.getElementById('plusamountpersec').
textContent=plusamountpersec;
}
}
const auto10000 = function(){
if (amountK > 920000){
amountK = amountK - 920000; //920000減らす
document.getElementById('amountK').
textContent=amountK;
plusamountpersec = plusamountpersec + 10000; //1秒で増える数を10000増やす
document.getElementById('plusamountpersec').
textContent=plusamountpersec;
}
}
const auto1000000 = function(){
if (amountK > 91000000){
amountK = amountK - 91000000; //91000000減らす
document.getElementById('amountK').
textContent=amountK;
plusamountpersec = plusamountpersec + 1000000; //1秒で増える数を1000000増やす
document.getElementById('plusamountpersec').
textContent=plusamountpersec;
}
}
//備考(本プログラムとは関係なし)
//検討クリッカーでは、最初に+1ボタンを
//押したときにカウントイベントを発動させることで
//正確な時間を測りたいと思う。
//countUp()関数の中身
function countUp(){
//現在の時間からstartボタンを引いた時間を定数dに格納
const d=new Date(Date.now()- startTime);
//d.getMinutes()で定数dに格納されている「分」の部分を取り出す
//padStart()で必要な桁数を指定
const m=String(d.getMinutes()).padStart(2,"0");
const s=String(d.getSeconds()).padStart(2,"0");
const ms =String(d.getMilliseconds()).padStart(3,"0");
//定数タイマーのテキストに上記で取り出した時間を表示
timer.textContent = `${m}:${s},${ms}`;
//setTimeout()で関数countUp()を10みり秒ごとに繰り返す
setTimeout(() => {
countUp();
}, 10);
}
//1秒ごとにplusamountpersec分amountKを追加する
const autoplusing = setInterval(function(){
console.log(autoplusing);
amountK = amountK + plusamountpersec;
document.getElementById('amountK').
textContent = amountK;
}, 1000);