-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas-controller.js
2733 lines (2485 loc) · 99.1 KB
/
canvas-controller.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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Pacman
// music stuff @advaita
var audioElement = new Audio('pacman_beat_3.mp3');
var eatsound = new Audio('pacman_eat_sound.mp3');
eatsound.volume = 0.5;
var deathsound = new Audio('pacman_death_sound.mp3');
var ghosteatspacman = new Audio('ghost_eats_pacman.mp3');
var eatghostsound = new Audio('pacman_eats_ghost.mp3');
var winsound = new Audio('pacman_gg_win_music.mp3');
// audio
audioElement.addEventListener("canplaythrough", event => {
// playit
audioElement.play();
var playable;
if (audioElement.duration > 0 && !audioElement.paused){
playable = true;
} else {
playable = false;
// notif
if (!playable && localStorage.getItem('audionotif') != 'dontshow'){
var notif = document.getElementById('notif');
notif.style.display = "block";
notif.innerHTML = `<h3 style="color:rgb(255, 255, 255);">Unable to play Audio. Check audio permissions and try again.</h3>
<a href="https://github.com/Skparab1/snake/blob/main/fix-audio.md" target="_blank"><button class="notif-button" style="position: absolute; left: 700px; top: 5px;">How to allow audio</button></a>
<button class="notif-button" style="position: absolute; left: 900px; top: 5px;" onclick="notif.style.display = 'none';">Dismiss</button>
<button class="notif-button" style="position: absolute; left: 1010px; top: 5px;" onclick="notif.style.display = 'none'; localStorage.setItem('audionotif','dontshow');">Dont show again</button>`;
}
}
});
// audio vars
audioElement.controls = true;
audioElement.loop = true;
let volume = document.querySelector("#volume-control");
volume.addEventListener("change", function(e) {
audioElement.volume = e.currentTarget.value/100;
})
let musictimeload = localStorage.getItem('musictime');
// audio continuer
if (musictimeload != null && parseFloat(musictimeload) < 130){
audioElement.currentTime = parseFloat(musictimeload);
}
// theme functions
function maketheme(id,clr){
let ab = document.getElementById(id);
ab.style.color = clr;
}
function clrbtn(id,clr){
let ab = document.getElementById(id);
ab.style.backgroundColor = clr;
ab.style.borderColor = clr;
}
function clrbtn1(id,clr){
let ab = document.getElementById(id);
ab.style.borderColor = clr;
}
function settheme(clr){
setclr = clr; // to make ritam not complain about how long this is i mean he complains about useful comments smh
maketheme('header1',setclr);maketheme('header2',setclr);maketheme('header3',setclr);maketheme('title',setclr);maketheme('settings',setclr);maketheme('theme',setclr);clrbtn1('box',setclr);clrbtn1('left-panel',setclr);clrbtn1('rulesbtn',setclr);maketheme('es',setclr);maketheme('sf',setclr);clrbtn1('mode',setclr);maketheme('mode',setclr);maketheme('rules',setclr);clrbtn1('contributersbtn',setclr);maketheme('contributers',setclr);clrbtn1('leaderboardbtn',setclr);maketheme('leaderboard',setclr);maketheme('audio',setclr);clrbtn1('audiobtn',setclr);maketheme('audio-toggle',setclr);clrbtn1('right-panel',setclr);maketheme('info',setclr);maketheme('name',setclr);maketheme('score',setclr);maketheme('best',setclr);maketheme('time',setclr);maketheme('display',setclr);maketheme('game-controls',setclr);clrbtn('up',setclr);clrbtn('left',setclr);clrbtn('down',setclr);clrbtn('right',setclr); maketheme('oth',setclr);clrbtn1('contributersbtn1',setclr);clrbtn1('contributersbtn2',setclr);clrbtn1('contributersbtn3',setclr);maketheme('cb1',setclr); maketheme('cb2',setclr);maketheme('cb3',setclr);
}
// censorer
function checkcensor(inp){
let cr = 0;
while (cr < censored.length){
if (inp.toLowerCase().includes(censored[cr].toLowerCase())){
return true;
}
cr += 1;
}
return false
}
// animate plus
function plus10(eh){
(async () => {
p10 = document.getElementById('plus10');
if (eh != null){
p10.textContent = eh;
} else {
p10.textContent = '+ 10';
}
let mover = byte*10;
p10.style.left = (window.innerWidth/2 - (byte*(boardSize+2)))/2 + basex + (byte*5) + 50 +'px';
while (mover > byte*7){
p10.style.top = mover +'px';
mover = mover - (mover-byte*6.9)/10;
p10.style.color = 'rgba(255,255,255,'+(((byte*6.9-mover)/(byte*3))+1)+')';
await sleep(2);
}
let alpha2 = 1;
while (alpha2 > 0){
p10.style.color = 'rgba(255,255,255,'+alpha2+')';
alpha2 -= 0.01;
await sleep(2);
}
})();
}
// reset after life lost in og mode
function resetboard(){
xpos = (height)/(boardSize+2)*0.5+(height)/(boardSize+2)*3+window.innerWidth/4;
ypos = (height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25;
thepos = [xpos,ypos];
thepos = nearestgp(thepos);
g1pos = [(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*7.25+window.innerWidth/4,(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25];
g2pos = [(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*8.25+window.innerWidth/4,(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25];
g3pos = [(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*9.25+window.innerWidth/4,(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25];
g4pos = [(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25+window.innerWidth/4,(height)/(boardSize+2)*0.5+(height)/(boardSize+2)*10.25];
fpslst = [];
lastfps = Date.now();
speed = basespeed;
//counter = 0; // this causes problems
kickedoff1 = true;
kickedoff2 = true;
kickedoff3 = true;
kickedoff4 = true;
}
// reset speed in case user leaves
// earlier this was a notif but it sometimes falsely triggers
function resetspeed(){
fpslst = [];
lastfps = Date.now();
speed = basespeed;
}
// vaars
const boardSize = 16; //so 20 means 20x20 and 40 would be 40x40 and you can change it to anything you want
const speedfactor = 189; //directly porportional to these many pixels per second (but not exactly)
var eyesize = 2 // squarelength/this pixels
const borderleniance = 0.5 // the game will ignore a wall hit as long as it is less than 0.5 boxes away from the border
const endcurtainspeed = 0.25 // seconds wait in between frames of each pixel expansion (for game over animation)
var lostlives = 0;
var counter = 0; // i got it finally
var keylog = 'https://skparab1.github.io/pacman/generateanim/?';
// for 3 life only
var l2counter = 0;
var l3counter = 0;
// half of these are useless so clean it up
var storeendspeed = 0;
var startspeed = 0;
var capturedspeed = false;
var randlog = '';
var url = 'https://skparab1.github.io/pacman/generatesrc?';
var difficulty = localStorage.getItem('pacmode');
if (difficulty == null){
localStorage.setItem('pacmode','normal');
difficulty = 'normal';
}
// mode
let mode = document.getElementById('mode');
mode.value = difficulty;
let fmode = window.location.href.includes('funny');
// these are the 3 vars that control difficulty levels
var ghspeedfactor = 0.975; // relative to the speed of pacman
var dtimer = 6; // the time at which itl stop running away
var pushtime = 6; // time at which itl start blinking aback to reg mode
// set difficulty vars
if (difficulty == 'hard'){
ghspeedfactor = 1; // max
dtimer = 2;
pushtime = 4;
} else if (difficulty == 'normal'){
ghspeedfactor = 0.975;
dtimer = 4;
pushtime = 6;
} else if (difficulty == 'easy'){
ghspeedfactor = 0.90;
dtimer = 6;
pushtime = 6;
} else if (difficulty == 'very easy'){
ghspeedfactor = 0.75;
dtimer = 7;
pushtime = 9;
} else if (difficulty == 'OG'){
ghspeedfactor = 1; // max
dtimer = 2;
pushtime = 4;
}
// sfx settings
var sfx = localStorage.getItem('sfx');
var eatsfx = localStorage.getItem('eatsfx');
if (sfx == null){
sfx = true;
} else {
if (sfx == 'true'){
sfx = true;
} else {
sfx = false;
}
}
if (eatsfx == null){
eatsfx = true;
} else {
if (eatsfx == 'true'){
eatsfx = true;
} else {
eatsfx = false;
}
}
// theme stuff
var lost = false;
var theme = localStorage.getItem('theme');
if (theme == null){
theme = 'black';
}
if (theme == 'white' || theme == 'rgb(255,255,255)'){
settheme('black'); // opp color because contrast color
}
document.body.style.background = theme;
var rulesModal1 = document.getElementById('rules-modal');
var best = localStorage.getItem("bestpac");
// more vars
var lastfps = Date.now();
var avgfps = 0;
var fpslst = [];
var won = false;
var closedintro = true;
var lastname = '';
// testing mode dont touch
testingmode = window.location.href.includes('tmode');
// we dont talk abt this
var censored = "tawt;erohw a fo nos;hctib a fo nos;tuls;rekcufretsis;ssa tihs;tihs;kcirp;ssip;aggin;rekcufrehtom;tihs ni;tihsesroh;tihs yloh;lleh;nmadsdog;nmaddog;kcuf;reggirf;rekcufrehtaf;gniffe;nmad;tnuc;parc;rekcuskcoc;kcoc;rekcuf-dlihc;tihsllub;reggub;rekcufrehtorb;skcollob;hctib;dratsab;elohssa;ssa;esra";
censored = censored.split("").reverse().join("").split(";");
var firstrender = true;
//console.log(censored);
// name stuff
var name1 = localStorage.getItem('name');
var nameinput = document.getElementById('name-input');
if (name1 == null){
name1 = '';
rulesModal1.classList.toggle('visible');
rulesModal1.classList.toggle('hidden');
overlay.classList.toggle('visible');
overlay.classList.toggle('hidden');
} else {
nameinput.value = name1;
}
var namedisp = document.getElementById('name');
namedisp.textContent = name1;
localStorage.setItem('name',name1);
// read all the localstorage
if (best == null){
localStorage.setItem("bestpac",'0');
//openintro();
best = 0;
}
// draw line
function drawline(x,y,x1,y1,clr){
ctx.beginPath();
ctx.lineWidth = 4*scalefactor;
ctx.strokeStyle = clr;
ctx.fillStyle = clr;
ctx.moveTo(x,y);
ctx.lineTo(x1,y1)
ctx.stroke();
}
// random generation functions
function getrand() {
return Math.floor(Math.random() * 10); // 9 out of 10 cases go regualr way
}
function getrand2() {
return Math.floor(Math.random() * 3)-1;
}
function getrand3() {
let gr = Math.floor(Math.random() * 2);
if (gr == 0){
gr = -speed*ghspeedfactor;
} else {
gr = speed*ghspeedfactor
}
return gr;
}
function getranddir() {
//alert('getting rand dir'); //stfu
let gr2 = getrand();
let d;
if (gr2 >= 3){
d = [0,getrand3()];
} else {
d = [getrand3(),0];
}
randlog = randlog+(d[0]/(speed*ghspeedfactor))+','+(d[1]/(speed*ghspeedfactor))+';';
return d;
}
// this is useless no cap //stfu
function getrandnum(low,cap) {
return (Math.random() * (cap-low))+low; // 9 out of 10 cases go regualr way
}
// to make the ghosts dumb in blue mode
function getoppdir(dir,pos,gh){
//return dir;
if (activationclr && ((!got[0] && gh == 1) || (!got[1] && gh == 2) || (!got[2] && gh == 3) || (!got[3] && gh == 4)) && (Date.now() - activationtimer)/1000 <= dtimer){ // lmfao 4 is gud or eveen 3.5 dont wanna risk being too ez technical best 6 difficulty btw
//console.log('got opp');
return [-dir[0],-dir[1]];
} else {
return dir;
}
}
// for confetti shhhh
function drawdimond(x,y){
ctx.beginPath();
ctx.moveTo(x,y-12.5);
ctx.lineTo(x+12.5,y);
ctx.lineTo(x,y+12.5);
ctx.lineTo(x-12.5,y);
ctx.fill();
}
// returns boolean of whether going right is allowed or not for given pos
function getrightblock(pos){
let ct11 = 0;
let rejected = false;
while (ct11 < rightblockghost.length && !rejected){
if (pos[0] >= rightblockghost[ct11][0]+byte/2 && pos[0] <= rightblockghost[ct11][1]+byte/2 && pos[1] >= rightblockghost[ct11][2] && pos[1] <= rightblockghost[ct11][3]){
rejected = true;
return true;
}
ct11 += 1;
}
return false;
}
// returns boolean of whether going left is allowed or not for given pos
function getleftblock(pos){
let ct11 = 0;
let rejected = false;
while (ct11 < leftblockghost.length && !rejected){
if (pos[0] >= leftblockghost[ct11][0]-byte/2 && pos[0] <= leftblockghost[ct11][1]-byte/2 && pos[1] >= leftblockghost[ct11][2] && pos[1] <= leftblockghost[ct11][3]){
rejected = true;
return true;
}
ct11 += 1;
}
return false;
}
// goin up allowed or not
function getupblock(pos){
let ct11 = 0;
let rejected = false;
while (ct11 < upblockghost.length && !rejected){
if (pos[0] >= upblockghost[ct11][0] && pos[0] <= upblockghost[ct11][1] && pos[1] >= upblockghost[ct11][2]-byte/2 && pos[1] <= upblockghost[ct11][3]-byte/2){
rejected = true;
return true;
}
ct11 += 1;
}
return false;
}
// goin down allowed or not
function getdownblock(pos){
let ct11 = 0;
let rejected = false;
while (ct11 < downblockghost.length && !rejected){
if (pos[0] >= downblockghost[ct11][0] && pos[0] <= downblockghost[ct11][1] && pos[1] >= downblockghost[ct11][2]+byte/2 && pos[1] <= downblockghost[ct11][3]+byte/2){
rejected = true;
return true;
}
ct11 += 1;
}
return false;
}
// if at intersection
function atintersection(pos){
let inter = 0;
while (inter < intersection.length){
if (pos[0] >= intersection[inter][0] && pos[0] <= intersection[inter][1] && pos[1] >= intersection[inter][2] && pos[1] <= intersection[inter][3]){
return true;
}
inter += 1;
}
return false;
}
// nearest gridpos
function nearestgp(pos){
// we expect it to be +- 0.1 off
let nx = window.innerWidth/4 + byte/2;
while (nx < window.innerWidth/4 + byte*(boardSize+2)){
let ny = byte/2;
while (ny < byte*(boardSize+2)){
if (Math.abs(pos[0]-nx) < byte/2 && Math.abs(pos[1]-ny) < byte/2){
return [nx,ny];
}
ny += byte;
}
nx += byte;
}
return [0,0];
}
// nearst gp y only
function nearestgpy(pos){
// we expect it to be +- 0.1 off
let nx = window.innerWidth/4 + byte/2;
while (nx < window.innerWidth/4 + byte*(boardSize+2)){
let ny = byte/2;
while (ny < byte*(boardSize+2)){
if (Math.abs(pos[0]-nx) < byte/2 && Math.abs(pos[1]-ny) < byte/2){
return [pos[0],ny];
}
ny += byte;
}
nx += byte;
}
return [0,0];
}
// nearest gp x only
function nearestgpx(pos){
// we expect it to be +- 0.1 off
let nx = window.innerWidth/4 + byte/2;
while (nx < window.innerWidth/4 + byte*(boardSize+2)){
let ny = byte/2;
while (ny < byte*(boardSize+2)){
if (Math.abs(pos[0]-nx) < byte/2 && Math.abs(pos[1]-ny) < byte/2){
return [nx,pos[1]];
}
ny += byte;
}
nx += byte;
}
return [0,0];
}
// ghost mover algoirthm
function moveghost(pos,dir,timer1,gh){
// ghostmover function
// descision if at intersection and yeah dont turn 2 times at the same intersection thats a waste of processing
if (atintersection(pos) && timer1 > 25){
pos = nearestgp(pos); // want a gridpos for uh descision
if (dir[0] != 0){ // going right or left
if (thepos[1] > pos[1] && Math.abs(thepos[1]-pos[1]) > byte/4){ // not in same line but pacman is below
if (!getdownblock(pos)){ // below if allowed
dir = [0,speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
pos = nearestgp(pos);
}
} else if (thepos[1] < pos[1] && Math.abs(thepos[1]-pos[1]) > byte/4){ //pac above
if (!getupblock(pos)){ // up if allowed
dir = [0,-speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
pos = nearestgp(pos);
}
}
timer1 = 0;
} else { // going up or down
if (thepos[0] < pos[0] && Math.abs(thepos[0]-pos[0]) > byte/4){ // not in same line but left
if (!getleftblock(pos)){ // left if allowed
dir = [-speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
pos = nearestgp(pos);
}
} else if (thepos[0] > pos[0] && Math.abs(thepos[0]-pos[0]) > byte/4){
if (!getrightblock(pos)){ // right if allowed
dir = [speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
pos = nearestgp(pos);
}
}
timer1 = 0;
}
}
timer1 += 1; // upgrade obv
// if its not at an intersection // dont rlly need to do anything unless its gonna crash
if (dir[0] > 0){ // moving right
if (getrightblock(pos) && !atintersection(pos) && timer1 > 25){
if (thepos[1] > pos[1]){
dir = [0,speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
} else if (thepos[1] < pos[1]){
dir = [0,-speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
}
timer1 = 0;
} else if (!getrightblock(pos)){
pos = [pos[0]+dir[0],pos[1]+dir[1]];
}
} else if (dir[0] < 0){ // moving left
if (getleftblock(pos) && !atintersection(pos) && timer1 > 25){
if (thepos[1] > pos[1]){
dir = [0,speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
} else if (thepos[1] < pos[1]){
dir = [0,-speed*ghspeedfactor];
dir = getoppdir(dir,pos,gh);
}
timer1 = 0;
} else if (!getleftblock(pos)){
pos = [pos[0]+dir[0],pos[1]+dir[1]];
}
} else if (dir[1] < 0){ // moving up
if (getupblock(pos) && !atintersection(pos) && timer1 > 25){
if (thepos[0] > pos[0]){
dir = [speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
} else if (thepos[0] < pos[0]){
dir = [-speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
}
timer1 = 0;
} else if (!getupblock(pos)){
pos = [pos[0]+dir[0],pos[1]+dir[1]];
}
} else if (dir[1] > 0){ // moving down
if (getdownblock(pos) && !atintersection(pos) && timer1 > 25){
if (thepos[0] > pos[0]){
dir = [speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
} else if (thepos[0] < pos[0]){
dir = [-speed*ghspeedfactor,0];
dir = getoppdir(dir,pos,gh);
}
timer1 = 0;
} else if (!getdownblock(pos)){
pos = [pos[0]+dir[0],pos[1]+dir[1]];
}
}
// ok return finally
return [pos,dir,timer1];
}
// this is for the pingponging back to the ghost box when eaten in blue mode
// basically there are pushzones defined by rightpush leftpush yk and it just uses that to push the ghost
function returnghost(pos,dir){
let sn = 0;
while (sn < rightpush.length){ // if its in rightpush zone
if (pos[0] > rightpush[sn][0] && pos[0] < rightpush[sn][1] && pos[1] > rightpush[sn][2] && pos[1] < rightpush[sn][3]){
dir = [speed*2,0];
pos = nearestgpy(pos);
}
sn += 1;
}
sn = 0;
while (sn < leftpush.length){ // if in leftpush zione
if (pos[0] > leftpush[sn][0] && pos[0] < leftpush[sn][1] && pos[1] > leftpush[sn][2] && pos[1] < leftpush[sn][3]){
dir = [-speed*2,0];
pos = nearestgpy(pos);
}
sn += 1;
}
sn = 0;
while (sn < uppush.length){ // if in up zone
if (pos[0] > uppush[sn][0] && pos[0] < uppush[sn][1] && pos[1] > uppush[sn][2] && pos[1] < uppush[sn][3]){
dir = [0,-speed*2];
pos = nearestgpx(pos);
}
sn += 1;
}
sn = 0;
while (sn < downpush.length){ // down zone
if (pos[0] > downpush[sn][0] && pos[0] < downpush[sn][1] && pos[1] > downpush[sn][2] && pos[1] < downpush[sn][3]){
dir = [0,speed*2];
pos = nearestgpx(pos);
}
sn += 1;
}
return [pos,dir];
}
// if its in the ghost box i actually dk what this is for u can check if u want
function inghostbox(pos){
return (pos[0] > basex+byte*7 && pos[0] < basex+byte*11 && pos[1] > byte*10 && pos[1] < byte*12)
}
// draw the board
// this is a main function btw
function drawboard(){
ctx.beginPath();
let x = 0;
let actx = window.innerWidth/4+byte;
// clear else keeps adding
while (x < boardSize*2-1){ // this isnt actually that useful anymore
let y = 0;
let acty = byte/2;
while (y < boardSize*2-1){
acty += (height)/(boardSize+2)*0.51;
y += 1;
// grid
//ctx.strokeRect(actx,acty,(height)/(boardSize+2),(height)/(boardSize+2));
//dots
ctx.fillStyle = dotcolor;
let ed = 0;
let deactivated = false;
while (ed < eraseddots.length){
if (Math.abs(eraseddots[ed][0] - (actx+byte/2+byte/20)) < byte/4 && Math.abs(eraseddots[ed][1] - (acty+byte/2+byte/20)) < byte/4){
deactivated = true;
}
ed += 1;
}
// smth abt dots i dont actually remember
if (!deactivated){
if ((x == 0 && y == 1) || (x == 30 && y == 1) || (x == 30 && y == 31) || (x == 0 && y == 31)){
ctx.beginPath();
ctx.arc(actx+byte/2+byte/40,acty+byte/2,(height)/(boardSize+2)/5,0,2*Math.PI);
ctx.fill();
} else {
ctx.fillRect(actx+byte/2,acty+byte/2,(height)/(boardSize+2)/10,(height)/(boardSize+2)/10);
}
}
//console.log(eraseddots.length);
if (firstrender){
dotspos.push([actx+byte/2+byte/20,acty+byte/2+byte/20]);
}
}
actx += (height)/(boardSize+2)*0.51;
x += 1;
}
firstrender = false;
// the exit dot overlay
ctx.fillStyle = theme;
ctx.fillRect(window.innerWidth/4+byte*1,byte*9-4,byte*2+4,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*15-4,byte*9-4,byte*2+8,byte*2+8);
// def colors of board
var linecolor;
var limecolor;
var yellowcolor;
var redcolor;
var ghostbcolor;
if (theme == 'white' || theme == 'rgb(255,255,255)'){
linecolor = "rgb(0, 0, 255)";
dotcolor = "brown";
limecolor = 'rgb(10, 215, 65)'
yellowcolor = 'rgb(240, 240, 110)'
redcolor = 'rgb(180, 30, 30)'
ghostbcolor = 'rgb(0, 0, 0)'
} else {
linecolor = "rgb(42, 198, 250)";
dotcolor = "orange";
limecolor = 'rgb(0, 255, 0)'
yellowcolor = 'rgb(255, 255, 0)'
redcolor = 'rgb(255, 0, 0)'
ghostbcolor = 'rgb(255, 255, 255)'
}
//----------------------ok all the board drawing bs is after this so yeah scroll past if u want--------
// its messy ik
// but at least i commented
//console.log(theme);
ctx.strokeStyle = linecolor;
ctx.lineWidth = 4*scalefactor;
let leniance = ((height)/(boardSize+2))*borderleniance;
bounderies = [window.innerWidth/4+(height)/(boardSize+2)*1.5-leniance+10*scalefactor,(height)/(boardSize+2)*1.5-leniance+10*scalefactor,(window.innerWidth/4+height*((boardSize-1)/boardSize))-(height)/(boardSize+2)/2.5+leniance-10*scalefactor,height*(boardSize-1)/boardSize-(height)/(boardSize+2)/2+leniance-10*scalefactor];
ctx.strokeRect(window.innerWidth/4+(height)/(boardSize+2),(height)/(boardSize+2),byte*boardSize,byte*boardSize);
ctx.strokeRect(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,(height)/(boardSize+2)-10*scalefactor,byte*boardSize+20*scalefactor,byte*boardSize+20*scalefactor);
// some dot cover fillrects
ctx.fillRect(window.innerWidth/4+byte*1,byte*11,byte*2+4,byte*1+4);
ctx.fillRect(window.innerWidth/4+byte*14.75,byte*11,byte*2+4,byte*1+4);
ctx.fillRect(window.innerWidth/4+(height)/(boardSize+2)-byte,byte*(boardSize/2)+byte*1+10*scalefactor,byte*3,byte*2.5);
ctx.fillRect(window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+byte*1,byte*3,byte*3);
//the enterances and exits
drawline(window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+3*byte+2,window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+3*byte+2+byte,theme);
drawline(window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+3*byte+2+byte,window.innerWidth/4+(height)/(boardSize+2)+2*byte,byte*(boardSize/2)+3*byte+2+byte,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)+2*byte,byte*(boardSize/2)+3*byte+2+byte,2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+3*byte,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+4*byte-10*scalefactor,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+4*byte-10*scalefactor,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor-2,byte*(boardSize/2)+3*byte,2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+3*byte,linecolor);
// hmm there shud be a break somewhere here idk
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor+2,byte*(boardSize/2)+3*byte+10*scalefactor,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+3*byte+10*scalefactor,linecolor);
drawline(2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+3*byte+10*scalefactor,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+4*byte-10*scalefactor,linecolor);
drawline(window.innerWidth/4+byte-10*scalefactor-1,byte*11+10*scalefactor+2,window.innerWidth/4+byte-10*scalefactor-1,byte*12-10*scalefactor-2,theme)
drawline(window.innerWidth/4+byte-10*scalefactor+2,byte*11+10*scalefactor+2,window.innerWidth/4+byte-10*scalefactor+2,byte*12-10*scalefactor-2,theme)
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*3+2,window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*3+10*scalefactor,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+byte,2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+byte,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+2+byte,window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+10*scalefactor-2+byte,theme);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+10*scalefactor+byte,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+10*scalefactor+byte,linecolor);
drawline(2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+byte,2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+byte*2,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)-10*scalefactor+byte*2,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)-10*scalefactor+byte*2,linecolor);
drawline(2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte+10*scalefactor,2*byte+window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*2-10*scalefactor,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*2,2*byte+window.innerWidth/4+(height)/(boardSize+2),byte*(boardSize/2)+byte*2,linecolor);
drawline(window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*2,window.innerWidth/4+(height)/(boardSize+2)-10*scalefactor,byte*(boardSize/2)+byte*2-10*scalefactor,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+10*scalefactor,byte*(boardSize/2)+3*byte,window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+3*byte,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte,byte*(boardSize/2)+byte,window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+byte,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte+scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte+scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*2,window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+byte*2,linecolor);
drawline(window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+byte+scalefactor,window.innerWidth/4+byte*boardSize-byte,byte*(boardSize/2)+byte*2,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte+scalefactor*10,window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*2-scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*2-scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*2-scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte+scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*2-scalefactor*10,window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*2,linecolor);
// all the fillrects to cover the uneeded dots
// repettitive ik
// i suppose i couldve put them in an arr and then iterated
ctx.fillStyle = theme;
ctx.fillRect(window.innerWidth/4+byte*2+2-4,byte*2+2-4,byte+8,byte*6+8);
ctx.fillRect(window.innerWidth/4+byte*4+2-4,byte*2+2-4,byte*3+8,byte+8);
ctx.fillRect(window.innerWidth/4+byte*4+2-4,byte*4+2-4,byte*3+8,byte+8);
ctx.fillRect(window.innerWidth/4+byte*4+2-4,byte*4+2-4,byte*1+8,byte*3+8);
ctx.fillRect(window.innerWidth/4+byte*7-4,byte*9-4,byte*4+8,byte*3+8);
ctx.fillRect(window.innerWidth/4+byte*8-4,byte*1-4,byte*1+8,byte*5+8);
ctx.fillRect(window.innerWidth/4+byte*6-4,byte*6-4,byte*1+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*7-4,byte*7-4,byte*2+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*4-4,byte*8-4,byte*1+8,byte*4+8);
ctx.fillRect(window.innerWidth/4+byte*5-4,byte*9-4,byte*1+8,byte*3+8);
ctx.fillRect(window.innerWidth/4+byte*12,byte*9-4,byte*2+8,byte*3+8);
ctx.fillRect(window.innerWidth/4+byte*10-4,byte*2-4,byte*2+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*14-4,byte*2-4,byte*2+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*10-4,byte*2-4,byte*1+8,byte*6+8);
ctx.fillRect(window.innerWidth/4+byte*15-4,byte*2-4,byte*1+8,byte*6+8);
ctx.fillRect(window.innerWidth/4+byte*10-4,byte*7-4,byte*6+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*12-4,byte*4-4,byte*2+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*2-4,byte*13-4,byte*1+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*2-4,byte*15-4,byte*1+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*3-4,byte*15-4,byte*1+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*4-4,byte*13-4,byte*3+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*5-4,byte*14-4,byte*1+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*8-4,byte*13-4,byte*1+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*7-4,byte*15-4,byte*3+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*10-4,byte*13-4,byte*3+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*11-4,byte*14-4,byte*1+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*14-4,byte*13-4,byte*1+8,byte*2+8);
ctx.fillRect(window.innerWidth/4+byte*13-4,byte*15-4,byte*3+8,byte*1+8);
ctx.fillRect(window.innerWidth/4+byte*12-4,byte*1.75-4,byte*2+8,byte*0.5+8);
ctx.fillRect(window.innerWidth/4+byte*12-4,byte*2.75-4,byte*2+8,byte*0.5+8);
ctx.fillRect(window.innerWidth/4+byte*8-4,byte*9-4,byte*2+8,byte*1+8);
// middle dot in o enterance
//ctx.fillRect(window.innerWidth/4+byte*12.75,byte*2.25,byte*0.5+4,byte*0.5+4);
ctx.strokeStyle = linecolor;
ctx.beginPath();
// block 1
ctx.strokeStyle = redcolor;
ctx.strokeRect(window.innerWidth/4+byte*2,byte*2,byte,byte*6); // -10*scalefactor to make it fit but then it doesnt align
// block 2
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*4,byte*2,byte*3,byte);
// weird shape
drawline(window.innerWidth/4+byte*4,byte*4,window.innerWidth/4+byte*7,byte*4,yellowcolor);
drawline(window.innerWidth/4+byte*4,byte*4,window.innerWidth/4+byte*4,byte*7,yellowcolor);
drawline(window.innerWidth/4+byte*5,byte*5,window.innerWidth/4+byte*7,byte*5,yellowcolor);
drawline(window.innerWidth/4+byte*5,byte*5,window.innerWidth/4+byte*5,byte*7,yellowcolor);
drawline(window.innerWidth/4+byte*7,byte*4,window.innerWidth/4+byte*7,byte*5,yellowcolor);
drawline(window.innerWidth/4+byte*4,byte*7,window.innerWidth/4+byte*5,byte*7,yellowcolor);
ctx.fillStyle = theme;
// ghost box
ctx.strokeStyle = ghostbcolor;
ctx.strokeRect(window.innerWidth/4+byte*7,byte*10,byte*4,byte*2);
ctx.strokeRect(window.innerWidth/4+byte*7,byte*9,byte*1,byte*1);
ctx.strokeRect(window.innerWidth/4+byte*10,byte*9,byte*1,byte*1);
drawline(window.innerWidth/4+byte*7+2,byte*10-2,window.innerWidth/4+byte*11-2,byte*10-2,theme);
drawline(window.innerWidth/4+byte*7+2,byte*10+1,window.innerWidth/4+byte*11-2,byte*10+1,theme);
drawline(window.innerWidth/4+byte*8,byte*10-2,window.innerWidth/4+byte*10,byte*10-2,dotcolor);
// box 4
ctx.strokeStyle = linecolor;
ctx.fillStyle = theme;
ctx.strokeRect(window.innerWidth/4+byte*8,byte*1,byte,byte*5);
drawline(window.innerWidth/4+byte*8,byte-2,window.innerWidth/4+byte*9,byte-2,theme);
drawline(window.innerWidth/4+byte*8,byte+1,window.innerWidth/4+byte*9,byte+1,theme);
// another weird shape
drawline(window.innerWidth/4+byte*6,byte*6,window.innerWidth/4+byte*6,byte*8,redcolor);
drawline(window.innerWidth/4+byte*6,byte*8,window.innerWidth/4+byte*9,byte*8,redcolor);
drawline(window.innerWidth/4+byte*7,byte*7,window.innerWidth/4+byte*9,byte*7,redcolor);
drawline(window.innerWidth/4+byte*6,byte*6,window.innerWidth/4+byte*7,byte*6,redcolor);
drawline(window.innerWidth/4+byte*9,byte*8,window.innerWidth/4+byte*9,byte*7,redcolor);
drawline(window.innerWidth/4+byte*7,byte*6,window.innerWidth/4+byte*7,byte*7,redcolor);
// big o shape
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*10,byte*2,byte*6,byte*6);
drawline(window.innerWidth/4+byte*12,byte*2-1,window.innerWidth/4+byte*14,byte*2-1,theme);
drawline(window.innerWidth/4+byte*12,byte*2+2,window.innerWidth/4+byte*14,byte*2+2,theme);
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*11,byte*3,byte*4,byte*4);
drawline(window.innerWidth/4+byte*12,byte*3,window.innerWidth/4+byte*14,byte*3,theme);
ctx.strokeStyle = limecolor;
drawline(window.innerWidth/4+byte*12,byte*2,window.innerWidth/4+byte*12,byte*3)
drawline(window.innerWidth/4+byte*14,byte*2,window.innerWidth/4+byte*14,byte*3)
ctx.strokeRect(window.innerWidth/4+byte*12,byte*4,byte*2,byte*2);
//block 5 with a block on side
ctx.strokeStyle = yellowcolor;
ctx.strokeRect(window.innerWidth/4+byte*4,byte*9,byte*2,byte*3);
ctx.strokeRect(window.innerWidth/4+byte*4,byte*8,byte*1,byte*1);
drawline(window.innerWidth/4+byte*4+2,byte*9-1,window.innerWidth/4+byte*5-2,byte*9-1,theme);
drawline(window.innerWidth/4+byte*4+2,byte*9+2,window.innerWidth/4+byte*5-2,byte*9+2,theme);
// block 6 removed to push the ghost box up
ctx.strokeStyle = linecolor;
//ctx.strokeRect(window.innerWidth/4+byte*7,byte*9,byte*7,byte*1);
// block 7
ctx.strokeStyle = linecolor;
ctx.strokeRect(window.innerWidth/4+byte*15,byte*11,byte*2,byte*1);
ctx.strokeRect(window.innerWidth/4+byte*16,byte*13,byte*1,byte*1);
//ctx.fillStyle = theme;
ctx.fillRect(window.innerWidth/4+byte*16+2,byte*13+2,byte*1+2,byte*1-4);
drawline(window.innerWidth/4+byte*17+1,byte*11+2,window.innerWidth/4+byte*17+1,byte*12-2,theme);
drawline(window.innerWidth/4+byte*17-1,byte*11+2,window.innerWidth/4+byte*17-2,byte*12-2,theme);
drawline(window.innerWidth/4+byte*17-1,byte*14,window.innerWidth/4+byte*17-1,byte*14+8,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*4-scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*4-scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10,byte*(boardSize/2)+byte*3+scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*3+scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*4-scalefactor*10,window.innerWidth/4+byte*boardSize-byte+scalefactor*10,byte*(boardSize/2)+byte*3+scalefactor*10,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte*4-scalefactor*10,window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte*4,linecolor);
drawline(window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte*3,window.innerWidth/4+byte*boardSize+byte+scalefactor*10-1,byte*(boardSize/2)+byte*3+10*scalefactor,linecolor);
// t shape thing
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*13,byte*15,byte*3,byte*1);
ctx.strokeRect(window.innerWidth/4+byte*14,byte*13,byte*1,byte*2);
drawline(window.innerWidth/4+byte*14,byte*15+1,window.innerWidth/4+byte*15,byte*15+1,theme);
drawline(window.innerWidth/4+byte*14,byte*15-1,window.innerWidth/4+byte*15,byte*15-1,theme);
// 2nd t shape
ctx.strokeStyle = yellowcolor;
ctx.strokeRect(window.innerWidth/4+byte*10,byte*13,byte*3,byte*1);
ctx.strokeRect(window.innerWidth/4+byte*11,byte*14,byte*1,byte*2);
drawline(window.innerWidth/4+byte*11,byte*14+1,window.innerWidth/4+byte*12,byte*14+1,theme);
drawline(window.innerWidth/4+byte*11,byte*14-1,window.innerWidth/4+byte*12,byte*14-1,theme);
// 3rd t shape thing
ctx.strokeStyle = redcolor;
ctx.strokeRect(window.innerWidth/4+byte*7,byte*15,byte*3,byte*1);
ctx.strokeRect(window.innerWidth/4+byte*8,byte*13,byte*1,byte*2);
drawline(window.innerWidth/4+byte*8,byte*15+1,window.innerWidth/4+byte*9,byte*15+1,theme);
drawline(window.innerWidth/4+byte*8,byte*15-1,window.innerWidth/4+byte*9,byte*15-1,theme);
// block 8
ctx.strokeStyle = redcolor;
ctx.strokeRect(window.innerWidth/4+byte*12,byte*9,byte*2,byte*3);
// 4th t shape
ctx.strokeStyle = linecolor;
ctx.strokeRect(window.innerWidth/4+byte*5,byte*14,byte*1,byte*2);
ctx.strokeRect(window.innerWidth/4+byte*4,byte*13,byte*3,byte*1);
drawline(window.innerWidth/4+byte*6,byte*14-1,window.innerWidth/4+byte*5,byte*14-1,theme);
drawline(window.innerWidth/4+byte*6,byte*14+1,window.innerWidth/4+byte*5,byte*14+1,theme);
// l shaped thing
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*2,byte*15,byte*2,byte*1);
//drawline(window.innerWidth/4+byte*3-2,byte*15-1,window.innerWidth/4+byte*2+2,byte*15-1,theme);
//drawline(window.innerWidth/4+byte*3-2,byte*15+1,window.innerWidth/4+byte*2+2,byte*15+1,theme);
// block 9
ctx.strokeStyle = limecolor;
ctx.strokeRect(window.innerWidth/4+byte*2,byte*13,byte*1,byte*1);
// top stuff
ctx.fillStyle = 'gray';
ctx.font = byte*0.66+"px finlandica";
ctx.fillText('Difficulty: '+difficulty, basex+byte, 0.50*byte, byte*10);
ctx.font = byte*0.85+"px finlandica";
ctx.fillStyle = 'gray';
let ll = 0;
let txl = '';
while (ll < (3-lostlives) && difficulty == 'OG'){
txl += '♥';
ll += 1;
}
ctx.fillText(txl, basex+byte*15.75, 0.55*byte, byte*10);
// a bunch of test cases i think ill delete
// if u need them then git history
// ok i just saved 30 lines
}
// put in in terms of bytes, ill add a converter
// assign blocks
var rightblockpre = [[3,4,8,12],[1,2,2,8],[3,4,2,3],[10,11,9,12],[3,4,4,7],[1,2,11,12],[1,2,13,14],[1,2,15,16],[3,4,13,14],[4,5,14,16],[7,8,1,6],[5,6,6,8],[6,7,9,12],[7,8,13,15],[6,7,15,16],[9,10,2,8],[11,12,4,6],[14,15,3,7],[13,14,2,3],[16,17,1,9],[11,12,9,12],[14,15,9,10],[14,15,11,12],[15,16,13,14],[16,17,12,13],[9,10,13,14],[10,11,14,16],[13,14,13,15],[12,13,15,16],[16,17,14,17],[8.5,9.5,9,10]];
var leftblockpre = [[1,2,1,9],[3,4,2,8],[7,8,9,12],[1,2,12,17],[3,4,11,12],[3,4,9,10],[3,4,13,14],[4,5,15,16],[7,8,2,3],[7,8,4,5],[5,6,5,7],[5,6,8,9],[6,7,9,12],[7,8,13,14],[6,7,14,16],[7,8,6,7],[9,10,7,8],[9,10,1,6],[9,10,13,15],[10,11,15,16],[12,13,2,3],[11,12,3,7],[14,15,4,6],[16,17,2,8],[8.5,9.5,9,10],[14,15,9,12],[13,14,13,14],[12,13,14,16],[15,16,13,15],[16,17,15,16],[11.5,12,9,12]];
var upblockpre = [[1,8,1,2],[1,2,12,13],[16,17,12,13],[-20,2,10,11],[7,8,10,11],[10,11,10,11],[15,50,10,11],[2,3,8,9],[2,3,12,13],[2,4,16,17],[4,7,3,4],[4,5,7,8],[5,7,5,6],[4,6,12,13],[4,5,14,15],[5,6,16,17],[6,7,14,15],[7,8,8,9],[7,8,9,10],[10,11,9,10],[7,10,16,17],[7,11,12,13],[6,9,8,9],[8,9,6,7],[9,17,1,2],[11,12,3,4],[14,15,3,4],[12,14,6,7],[10,16,8,9],[12,14,12,13],[10,11,14,15],[11,12,16,17],[12,13,14,15],[13,16,16,17],[15,16,12,13],[16,17,14,15],[1,3,10,11],[15,17,10,11],[1,3,9,10],[15,17,9,10],[2,3,14,15]];
var downblockpre = [[3,4,14,15],[2,3,1,2],[1,3,8,9],[-20,2,10,11],[1,2,10,11],[15,50,10,11],[2,3,9,10],[2,3,12,13],[1,17,16,17],[4,7,1,2],[4,7,3,4],[6,7,5,6],[7,9,6,7],[4,5,7,8],[5,6,8,9],[4,7,12,13],[10,11,8,9],[7,8,8,9],[10,11,8,9],[7,8,14,15],[8,9,12,13],[9,10,14,15],[10,13,12,13],[13,14,14,15],[14,15,12,13],[15,16,14,15],[12,14,8,9],[15,17,10,11],[10,12,1,2],[14,16,1,2],[12,14,3,4],[11,15,6,7],[15,17,8,10],[7,11,8,9],[2,3,10,11],[16,17,12,13],[2,3,14,15],[7,11,10,11]];
// intersections
var intersectionpre = [[3,4,1,2],[12,13,1,2],[13,14,1,2],[3,4,3,4],[7,8,3,4],[7,8,5,6],[9,10,6,7],[3,4,7,8],[3,4,8,9],[5,6,7,8],[6,7,8,9],[9,10,8,9],[11,12,8,9],[14,15,8,9],[12,13,3,4],[13,14,3,4],[3,4,10,11],[3,4,12,13],[6,7,12,13],[11,12,12,13],[14,15,12,13],[7,8,12,13],[9,10,12,13],[13,14,12,13],[15,16,12,13],[1,2,14,15],[3,4,14,15],[4,5,16,17],[6,7,16,17],[10,11,16,17],[12,13,16,17],[1,2,1,2],[1,2,8,9],[7,8,1,2],[9,10,1,2],[16,17,1,2],[11,12,3,4],[11,12,6,7],[14,15,3,4],[14,15,6,7],[5,6,5,6],[7,8,6,7],[5,6,8,9],[16,17,8,9],[1,2,12,13],[1,2,16,17],[4,5,14,15],[6,7,14,15],[7,8,14,15],[9,10,14,15],[10,11,14,15],[12,13,14,15],[13,14,14,15],[15,16,14,15],[16,17,14,15],[16,17,16,17],[16,17,12,13]];
// pushers
var rightpushpre = [[1,7,1,2],[3,7,3,4],[1,3,8,9],[3,5,7,8],[5,7,5,6],[7,9,6,7],[5,8,8,9],[13,14,6,7],[11,12,3,4],[-2,3,10,11],[1,3,12,13],[4,6,12,13],[9,11,12,13],[2,3,14,15],[6,7,14,15],[12,13,14,15],[2,4,16,17],[5,6,16,17],[9,10,16,17]];
var leftpushpre = [[10,17,8,9],[10,17,1,2],[12,13,6,7],[14,15,3,4],[15,18,10,11],[7,9,12,13],[12,14,12,13],[15,17,12,13],[4,5,14,15],[10,11,14,15],[16,17,14,15],[7,9,16,17],[11,12,16,17],[13,16,16,17]];
var uppushpre = [[11,12,4,7],[14,15,4,7],[12,14,2,4],[3,4,8,15],[6,7,9,13],[11,12,9,13],[14,15,9,13],[1,2,13,17],[4,5,15,17],[6,7,15,17],[7,8,13,15],[9,10,13,15],[10,11,15,17],[12,13,15,17],[13,14,13,15],[15,16,13,15],[16,17,15,17],[1,2,16,17]];
var downpushpre = [[1,2,2,8],[3,4,2,7],[7,8,1,6],[5,6,6,8],[8,10,8,9],[9,10,1,8],[16,17,2,8]];
// these arrs will be filled after conversion
var rightblock = [];
var leftblock = [];
var upblock = [];
var downblock = [];
var rightpush = [];
var leftpush = [];
var uppush = [];
var downpush = [];
var intersection = [];
var playeatsound = 0;
// central unit
byte = 2*((window.innerHeight-100)/(16*2.2));
// hmm couldnt this have been in drawboard
// but whatever
var dotcolor;
if (theme == 'black'){
dotcolor = "orange";
} else {
dotcolor = "brown";
}
// all the converters
// convert all the block coordinates into pixels
let ctr = 0;
while (ctr < rightblockpre.length){
let subjarr = [];
subjarr.push(rightblockpre[ctr][0]*byte+window.innerWidth/4);
subjarr.push(rightblockpre[ctr][1]*byte+window.innerWidth/4);
subjarr.push(rightblockpre[ctr][2]*byte);
subjarr.push(rightblockpre[ctr][3]*byte);
rightblock.push(subjarr);
ctr += 1;
}
ctr = 0;
while (ctr < leftblockpre.length){
let subjarr = [];
subjarr.push(leftblockpre[ctr][0]*byte+window.innerWidth/4);
subjarr.push(leftblockpre[ctr][1]*byte+window.innerWidth/4);
subjarr.push(leftblockpre[ctr][2]*byte);
subjarr.push(leftblockpre[ctr][3]*byte);
leftblock.push(subjarr);
ctr += 1;
}
ctr = 0;
while (ctr < upblockpre.length){
let subjarr = [];
subjarr.push(upblockpre[ctr][0]*byte+window.innerWidth/4);
subjarr.push(upblockpre[ctr][1]*byte+window.innerWidth/4);
subjarr.push(upblockpre[ctr][2]*byte);
subjarr.push(upblockpre[ctr][3]*byte);
upblock.push(subjarr);
ctr += 1;
}
ctr = 0;
while (ctr < downblockpre.length){
let subjarr = [];
subjarr.push(downblockpre[ctr][0]*byte+window.innerWidth/4);
subjarr.push(downblockpre[ctr][1]*byte+window.innerWidth/4);
subjarr.push(downblockpre[ctr][2]*byte);
subjarr.push(downblockpre[ctr][3]*byte);
downblock.push(subjarr);
ctr += 1;
}
// intersection
ctr = 0;
while (ctr < intersectionpre.length){
let subjarr = [];
subjarr.push((intersectionpre[ctr][0]+0.38)*byte+window.innerWidth/4);
subjarr.push((intersectionpre[ctr][1]-0.38)*byte+window.innerWidth/4);
subjarr.push((intersectionpre[ctr][2]+0.38)*byte);
subjarr.push((intersectionpre[ctr][3]-0.38)*byte);
intersection.push(subjarr);