-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.js
437 lines (421 loc) · 27 KB
/
menu.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
//Fetch the mode info canvas element and its 2D drawing context
const modeStatsCanvas = document.getElementById("modeStatsCanvas");
const modeStatsCtx = modeStatsCanvas && modeStatsCanvas.getContext("2d");
//Fetch the overall grade canvas element and its 2D drawing context
const overallGradeCanvas = document.getElementById("overallGradeCanvas");
const overallGradeCtx = overallGradeCanvas && overallGradeCanvas.getContext("2d");
let modeStatsImage = new Image();
modeStatsImage.src = "img/modeInfo.png";
let digitsSmall = new Image();
digitsSmall.src = "img/main/digitsSmall.png";
let overallGradeImage = new Image();
overallGradeImage.src = "img/overallGrades.png";
let overallGradeInfoImage = new Image();
overallGradeInfoImage.src = "img/overallGradeInfo.png";
function switchToTab(x) {
inCampaign = (x == 2); //Set inCampaign to true if entering the campaign screen
switch(x) {
case 1:
onCampaignScreen = false;
backgroundColorDestination = [80, 120, 120];
document.getElementsByClassName("container")[0].style.top = "0";
document.getElementsByClassName("container")[0].style.left = "0";
document.getElementsByClassName("container")[1].style.top = "0";
document.getElementsByClassName("container")[1].style.left = "100vw";
document.getElementsByClassName("container")[2].style.top = "0";
document.getElementsByClassName("container")[2].style.left = "100vw";
document.getElementsByClassName("container")[3].style.top = "100vh";
document.getElementsByClassName("container")[3].style.left = "0";
break;
case 2:
onCampaignScreen = true;
settings.startingLevel = 0;
backgroundColorDestination = [50, 50, 50];
document.getElementsByClassName("container")[0].style.top = "0";
document.getElementsByClassName("container")[0].style.left = "-100vw";
document.getElementsByClassName("container")[1].style.top = "0";
document.getElementsByClassName("container")[1].style.left = "0";
document.getElementsByClassName("container")[2].style.top = "0";
document.getElementsByClassName("container")[2].style.left = "100vw";
document.getElementsByClassName("container")[3].style.top = "100vh";
document.getElementsByClassName("container")[3].style.left = "-100vw";
hideKeybinds();
hideSettings();
break;
case 3:
onCampaignScreen = false;
backgroundColorDestination = [100, 100, 100];
document.getElementsByClassName("container")[0].style.top = "0";
document.getElementsByClassName("container")[0].style.left = "-100vw";
document.getElementsByClassName("container")[1].style.top = "0";
document.getElementsByClassName("container")[1].style.left = "100vw";
document.getElementsByClassName("container")[2].style.top = "0";
document.getElementsByClassName("container")[2].style.left = "0";
document.getElementsByClassName("container")[3].style.top = "100vh";
document.getElementsByClassName("container")[3].style.left = "-100vw";
hideKeybinds();
hideSettings();
break;
case 4:
onCampaignScreen = false;
backgroundColorDestination = [50, 50, 50];
document.getElementsByClassName("container")[0].style.top = "-100vh";
document.getElementsByClassName("container")[0].style.left = "0";
document.getElementsByClassName("container")[1].style.top = "-100vh";
document.getElementsByClassName("container")[1].style.left = "100vw";
document.getElementsByClassName("container")[2].style.top = "-100vh";
document.getElementsByClassName("container")[2].style.left = "100vw";
document.getElementsByClassName("container")[3].style.top = "0";
document.getElementsByClassName("container")[3].style.left = "0";
hideKeybinds();
hideSettings();
break;
}
}
let currentMenuMode = 1;
let onCampaignScreen = false;
function selectMenuMode(x) {
let containerCenter;
if (document.getElementsByClassName("container")[1].style.display != "none") containerCenter = document.getElementById('modeSelectContainer').offsetHeight / 2; //Recalculate containerCenter
document.getElementsByClassName("menuArrow")[0].style.top = (containerCenter - 90) + "px";
document.getElementsByClassName("menuArrow")[1].style.top = (containerCenter + 90) + "px";
document.getElementsByClassName("menuArrow")[0].style.display = x!=1 ? "block" : "none";
document.getElementsByClassName("menuArrow")[1].style.display = x!=3 ? "block" : "none";
currentMenuMode = x;
switch(x) {
case 1:
setPreset("classicStyle");
document.getElementsByClassName("menuMode")[0].style.top = containerCenter + "px";
document.getElementsByClassName("menuMode")[1].style.top = (containerCenter + 200) + "px";
document.getElementsByClassName("menuMode")[2].style.top = (containerCenter + 400) + "px";
//document.getElementsByClassName("menuMode")[3].style.top = (containerCenter + 600) + "px";
document.getElementsByClassName("menuMode")[0].style.left = "60px";
document.getElementsByClassName("menuMode")[1].style.left = "10px";
document.getElementsByClassName("menuMode")[2].style.left = "10px";
//document.getElementsByClassName("menuMode")[3].style.left = "10px";
document.getElementsByClassName("menuMode")[0].style.filter = "none";
document.getElementsByClassName("menuMode")[1].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[2].style.filter = "brightness(0.7)";
//document.getElementsByClassName("menuMode")[3].style.filter = "brightness(0.7)";
break;
case 2:
setPreset("masterStyle");
document.getElementsByClassName("menuMode")[0].style.top = (containerCenter - 200) + "px";
document.getElementsByClassName("menuMode")[1].style.top = containerCenter + "px";
document.getElementsByClassName("menuMode")[2].style.top = (containerCenter + 200) + "px";
//document.getElementsByClassName("menuMode")[3].style.top = (containerCenter + 400) + "px";
document.getElementsByClassName("menuMode")[0].style.left = "10px";
document.getElementsByClassName("menuMode")[1].style.left = "60px";
document.getElementsByClassName("menuMode")[2].style.left = "10px";
//document.getElementsByClassName("menuMode")[3].style.left = "10px";
document.getElementsByClassName("menuMode")[0].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[1].style.filter = "none";
document.getElementsByClassName("menuMode")[2].style.filter = "brightness(0.7)";
//document.getElementsByClassName("menuMode")[3].style.filter = "brightness(0.7)";
break;
case 3:
setPreset("dragonStyle");
document.getElementsByClassName("menuMode")[0].style.top = (containerCenter - 400) + "px";
document.getElementsByClassName("menuMode")[1].style.top = (containerCenter - 200) + "px";
document.getElementsByClassName("menuMode")[2].style.top = containerCenter + "px";
//document.getElementsByClassName("menuMode")[3].style.top = (containerCenter + 200) + "px";
document.getElementsByClassName("menuMode")[0].style.left = "10px";
document.getElementsByClassName("menuMode")[1].style.left = "10px";
document.getElementsByClassName("menuMode")[2].style.left = "60px";
//document.getElementsByClassName("menuMode")[3].style.left = "10px";
document.getElementsByClassName("menuMode")[0].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[1].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[2].style.filter = "none";
//document.getElementsByClassName("menuMode")[3].style.filter = "brightness(0.7)";
break;
case 4:
document.getElementsByClassName("menuMode")[0].style.top = (containerCenter - 600) + "px";
document.getElementsByClassName("menuMode")[1].style.top = (containerCenter - 400) + "px";
document.getElementsByClassName("menuMode")[2].style.top = (containerCenter - 200) + "px";
//document.getElementsByClassName("menuMode")[3].style.top = containerCenter + "px";
document.getElementsByClassName("menuMode")[0].style.left = "10px";
document.getElementsByClassName("menuMode")[1].style.left = "10px";
document.getElementsByClassName("menuMode")[2].style.left = "10px";
//document.getElementsByClassName("menuMode")[3].style.left = "60px";
document.getElementsByClassName("menuMode")[0].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[1].style.filter = "brightness(0.7)";
document.getElementsByClassName("menuMode")[2].style.filter = "brightness(0.7)";
//document.getElementsByClassName("menuMode")[3].style.filter = "none";
break;
}
displayModeInfo(x);
}
selectMenuMode(1);
//Reselect the current menu mode on window resize
window.addEventListener("resize", function() {
if (!gamePlaying) selectMenuMode(currentMenuMode);
});
function displayModeInfo(x) {
//Overall grade info
overallGradeCtx.clearRect(0, 0, 140, 40);
overallGradeCtx.drawImage(overallGradeInfoImage, 8, 8);
let overallPower = Math.min(game.bestPowers[0],30000) + Math.min(game.bestPowers[1],30000) + Math.min(game.bestPowers[2],39000);
let overallGrade = Math.floor(overallPower / 3000);
overallGradeCtx.drawImage(overallGradeImage, 0, overallGrade*32, 48, 32, 92, 0, 48, 32);
//Overall power string
let overallPowerString = Math.floor(overallPower).toString();
if (overallPowerString == "0") overallPowerString = "";
for (let i = 0; i < (5-overallPowerString.length); i++) overallGradeCtx.drawImage(digitsSmall, 0, 24, 4, 6, 68 + i*4, 24, 4, 6); //Greyed out zeroes
let overallPowerColor = overallPower >= 99000 ? 3 : 0;
for (let i = 0; i < overallPowerString.length; i++) overallGradeCtx.drawImage(digitsSmall, overallPowerString[i] * 4, overallPowerColor * 6, 4, 6, 88 - (4*overallPowerString.length) + i*4, 24, 4, 6);
//Classic power string
let classicPowerString = Math.floor(Math.min(game.bestPowers[0],30000)).toString();
if (classicPowerString == "0") classicPowerString = "";
for (let i = 0; i < (5-classicPowerString.length); i++) overallGradeCtx.drawImage(digitsSmall, 0, 24, 4, 6, 11 + i*4, 32, 4, 6); //Greyed out zeroes
let classicPowerColor = game.bestPowers[0] >= 30000 ? 3 : 0;
for (let i = 0; i < classicPowerString.length; i++) overallGradeCtx.drawImage(digitsSmall, classicPowerString[i] * 4, classicPowerColor * 6, 4, 6, 31 - (4*classicPowerString.length) + i*4, 32, 4, 6);
//Master power string
let masterPowerString = Math.floor(Math.min(game.bestPowers[1],30000)).toString();
if (masterPowerString == "0") masterPowerString = "";
for (let i = 0; i < (5-masterPowerString.length); i++) overallGradeCtx.drawImage(digitsSmall, 0, 24, 4, 6, 39 + i*4, 32, 4, 6); //Greyed out zeroes
let masterPowerColor = game.bestPowers[1] >= 30000 ? 3 : 0;
for (let i = 0; i < masterPowerString.length; i++) overallGradeCtx.drawImage(digitsSmall, masterPowerString[i] * 4, masterPowerColor * 6, 4, 6, 59 - (4*masterPowerString.length) + i*4, 32, 4, 6);
//Dragon power string
let dragonPowerString = Math.floor(Math.min(game.bestPowers[2],39000)).toString();
if (dragonPowerString == "0") dragonPowerString = "";
for (let i = 0; i < (5-dragonPowerString.length); i++) overallGradeCtx.drawImage(digitsSmall, 0, 24, 4, 6, 67 + i*4, 32, 4, 6); //Greyed out zeroes
let dragonPowerColor = game.bestPowers[2] >= 39000 ? 3 : 0;
for (let i = 0; i < dragonPowerString.length; i++) overallGradeCtx.drawImage(digitsSmall, dragonPowerString[i] * 4, dragonPowerColor * 6, 4, 6, 87 - (4*dragonPowerString.length) + i*4, 32, 4, 6);
//Mode info
let bestPowerString, bestScoreString, bestLevelString, bestLevelColor;
switch(x) {
case 1:
document.getElementById("modeInfoImage").src = "img/style1.png";
document.getElementById("modeInfo").innerHTML = "<b>Info:</b><br>Reminiscent of classic tetris games.<br>-Scored like NES tetris (No combo! Best scores come from getting tetrises.)<br>-DAS gets faster as you go<br>-Hard drop is enabled! You can use it to get fast times.<br>-Classic style power is based on level reached, average section time, and points."
//document.getElementById("modeInfo").innerHTML += "<br><br><img src='img/medal1.png' style='height: 30px; vertical-align: middle'> <b>Bronze medal requirements:</b><br>-Best score: 150,000<br>-Best level: 700"
//document.getElementById("modeInfo").innerHTML += "<br><br><img src='img/medal2.png' style='height: 30px; vertical-align: middle'> <b>Silver medal requirements:</b><br>-Best score: 300,000<br>-Best level: 999<br>-All section times under 1:15:00"
modeStatsCtx.clearRect(0, 0, 130, 160);
modeStatsCtx.fillStyle = "#eaeaff";
modeStatsCtx.fillRect(0, 1, 129, 1);
modeStatsCtx.fillStyle = "#000008";
modeStatsCtx.fillRect(1, 2, 129, 1);
//Best power
modeStatsCtx.drawImage(modeStatsImage, 0, 0, 130, 8, 0, 8, 130, 8);
bestPowerString = Math.floor(game.bestPowers[0]).toString().padStart(5, "0");
for (let i = 0; i < bestPowerString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestPowerString[i] * 4, 0, 4, 6, 47 + i*4, 8, 4, 6);
}
modeStatsCtx.drawImage(modeStatsImage, 0, 8, 130, 8, 0, 16, 130, 8);
//Best score
modeStatsCtx.drawImage(modeStatsImage, 0, 24, 130, 16, 0, 24, 130, 16);
bestScoreString = Math.floor(game.bestScores[0]).toString();
for (let i = 0; i < bestScoreString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestScoreString[i] * 4, 0, 4, 6, 45 + i*4, 24, 4, 6);
}
//Best level
bestLevelString = Math.floor(game.bestLevels[0]).toString();
bestLevelColor = game.bestLevels[0] >= 999 ? 3 : 0;
for (let i = 0; i < bestLevelString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestLevelString[i] * 4, bestLevelColor * 6, 4, 6, 44 + i*4, 32, 4, 6);
}
//Best highest section time
if (game.bestLevels[0] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 48, 130, 8, 0, 40, 130, 8);
let bestHighestSectionTime = game.bestHighestSectionTimes[0];
let timeString = convertToTime(bestHighestSectionTime);
let timeColor = getTimeColor(bestHighestSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 40, 130, 8);
}
//Best average section time
if (game.bestLevels[0] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 56, 130, 8, 0, 48, 130, 8);
let bestAverageSectionTime = game.bestAverageSectionTimes[0];
let timeString = convertToTime(bestAverageSectionTime);
let timeColor = getTimeColor(bestAverageSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 48, 130, 8);
}
//Best individual section times
modeStatsCtx.drawImage(modeStatsImage, 0, 64, 130, 8, 0, 64, 130, 8);
for (let i = 0; i < 10; i++) {
if (game.classicStyleBestSectionTimes[i]) {
let sectionTime = game.classicStyleBestSectionTimes[i];
let timeString = convertToTime(sectionTime);
let sectionTimeColor = getTimeColor(sectionTime);
for (let j=0;j<timeString.length;j++) {
if (timeString[j] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[j])*4, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 0, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 4, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 8, 72+i*8, 4, 6);
}
}
break;
case 2:
document.getElementById("modeInfoImage").src = "img/style2.png";
document.getElementById("modeInfo").innerHTML = "<b>Info:</b><br>Reminiscent of Tetris: The Grand Master.<br>-Scored like TGM (Best scores come from combos!)<br>-Master style power is based on level reached and average section time.";
modeStatsCtx.clearRect(0, 0, 130, 160);
modeStatsCtx.fillStyle = "#eaeaff";
modeStatsCtx.fillRect(0, 1, 129, 1);
modeStatsCtx.fillStyle = "#000008";
modeStatsCtx.fillRect(1, 2, 129, 1);
//Best power
modeStatsCtx.drawImage(modeStatsImage, 0, 0, 130, 8, 0, 8, 130, 8);
bestPowerString = Math.floor(game.bestPowers[1]).toString().padStart(5, "0");
for (let i = 0; i < bestPowerString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestPowerString[i] * 4, 0, 4, 6, 47 + i*4, 8, 4, 6);
}
modeStatsCtx.drawImage(modeStatsImage, 0, 8, 130, 8, 0, 16, 130, 8);
//Best score
modeStatsCtx.drawImage(modeStatsImage, 0, 24, 130, 16, 0, 24, 130, 16);
bestScoreString = Math.floor(game.bestScores[1]).toString();
for (let i = 0; i < bestScoreString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestScoreString[i] * 4, 0, 4, 6, 45 + i*4, 24, 4, 6);
}
//Best level
bestLevelString = Math.floor(game.bestLevels[1]).toString();
bestLevelColor = game.bestLevels[1] >= 999 ? 3 : 0;
for (let i = 0; i < bestLevelString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestLevelString[i] * 4, bestLevelColor * 6, 4, 6, 44 + i*4, 32, 4, 6);
}
//Best highest section time
if (game.bestLevels[1] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 48, 130, 8, 0, 40, 130, 8);
let bestHighestSectionTime = game.bestHighestSectionTimes[1];
let timeString = convertToTime(bestHighestSectionTime);
let timeColor = getTimeColor(bestHighestSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 40, 130, 8);
}
//Best average section time
if (game.bestLevels[1] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 56, 130, 8, 0, 48, 130, 8);
let bestAverageSectionTime = game.bestAverageSectionTimes[1];
let timeString = convertToTime(bestAverageSectionTime);
let timeColor = getTimeColor(bestAverageSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 48, 130, 8);
}
//Best individual section times
modeStatsCtx.drawImage(modeStatsImage, 0, 64, 130, 8, 0, 64, 130, 8);
for (let i = 0; i < 10; i++) {
if (game.masterStyleBestSectionTimes[i]) {
let sectionTime = game.masterStyleBestSectionTimes[i];
let timeString = convertToTime(sectionTime);
let sectionTimeColor = getTimeColor(sectionTime);
for (let j=0;j<timeString.length;j++) {
if (timeString[j] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[j])*4, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 0, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 4, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 8, 72+i*8, 4, 6);
}
}
break;
case 3:
document.getElementById("modeInfoImage").src = "img/style3.png";
document.getElementById("modeInfo").innerHTML = "<b>Info:</b><br>Reminiscent of T.A. Death. Quite difficult!<br>-Scored like TGM (Best scores come from combos!)<br>-DAS, ARE and lock delay get faster as you go<br>-Dragon style power is based on level reached and average section time.";
modeStatsCtx.clearRect(0, 0, 130, 160);
modeStatsCtx.fillStyle = "#eaeaff";
modeStatsCtx.fillRect(0, 1, 129, 1);
modeStatsCtx.fillStyle = "#000008";
modeStatsCtx.fillRect(1, 2, 129, 1);
//Best power
modeStatsCtx.drawImage(modeStatsImage, 0, 0, 130, 8, 0, 8, 130, 8);
bestPowerString = Math.floor(game.bestPowers[2]).toString().padStart(5, "0");
for (let i = 0; i < bestPowerString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestPowerString[i] * 4, 0, 4, 6, 47 + i*4, 8, 4, 6);
}
modeStatsCtx.drawImage(modeStatsImage, 0, 16, 130, 8, 0, 16, 130, 8);
//Best score
modeStatsCtx.drawImage(modeStatsImage, 0, 24, 130, 16, 0, 24, 130, 16);
bestScoreString = Math.floor(game.bestScores[2]).toString();
for (let i = 0; i < bestScoreString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestScoreString[i] * 4, 0, 4, 6, 45 + i*4, 24, 4, 6);
}
//Best level
bestLevelString = Math.floor(game.bestLevels[2]).toString();
bestLevelColor = game.bestLevels[2] >= 999 ? 3 : 0;
for (let i = 0; i < bestLevelString.length; i++) {
modeStatsCtx.drawImage(digitsSmall, bestLevelString[i] * 4, bestLevelColor * 6, 4, 6, 44 + i*4, 32, 4, 6);
}
//Best highest section time
if (game.bestLevels[2] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 48, 130, 8, 0, 40, 130, 8);
let bestHighestSectionTime = game.bestHighestSectionTimes[2];
let timeString = convertToTime(bestHighestSectionTime);
let timeColor = getTimeColor(bestHighestSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 89 + i*4, 40, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 40, 130, 8);
}
//Best average section time
if (game.bestLevels[2] >= 999) {
modeStatsCtx.drawImage(modeStatsImage, 0, 56, 130, 8, 0, 48, 130, 8);
let bestAverageSectionTime = game.bestAverageSectionTimes[2];
let timeString = convertToTime(bestAverageSectionTime);
let timeColor = getTimeColor(bestAverageSectionTime);
for (let i=0;i<timeString.length;i++) {
if (timeString[i] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[i])*4, timeColor*6, 4, 6, 88 + i*4, 48, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(modeStatsImage, 0, 40, 130, 8, 0, 48, 130, 8);
}
//Best individual section times
modeStatsCtx.drawImage(modeStatsImage, 0, 64, 130, 8, 0, 64, 130, 8);
for (let i = 0; i < 10; i++) {
if (game.dragonStyleBestSectionTimes[i]) {
let sectionTime = game.dragonStyleBestSectionTimes[i];
let timeString = convertToTime(sectionTime);
let sectionTimeColor = getTimeColor(sectionTime);
for (let j=0;j<timeString.length;j++) {
if (timeString[j] == ":") {modeStatsCtx.drawImage(digitsSmall, 40, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
else {modeStatsCtx.drawImage(digitsSmall, parseInt(timeString[j])*4, sectionTimeColor*6, 4, 6, j*4, 72+i*8, 4, 6);}
}
}
else {
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 0, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 4, 72+i*8, 4, 6);
modeStatsCtx.drawImage(digitsSmall, 44, 0, 4, 6, 8, 72+i*8, 4, 6);
}
}
break;
case 4:
modeStatsCtx.clearRect(0, 0, 130, 160);
modeStatsCtx.fillStyle = "#eaeaff";
modeStatsCtx.fillRect(0, 1, 129, 1);
modeStatsCtx.fillStyle = "#000008";
modeStatsCtx.fillRect(1, 2, 129, 1);
document.getElementById("modeInfoImage").src = "img/style4.png";
document.getElementById("modeInfo").innerHTML = "The funny fishing minigame. Not yet implemented.";
break;
}
}