-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoardGame3.html
More file actions
825 lines (775 loc) · 22.7 KB
/
BoardGame3.html
File metadata and controls
825 lines (775 loc) · 22.7 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
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
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="query-3.1.0.min.js"></script>
<style>
@keyframes backgroundAnimate{
0%, 100%{
opacity:1;
}
50%{
opacity:0.75;
}
}
@keyframes spin{
0%, 100%{
transform:rotate(0deg);
}
50%{
transform:rotate(360deg);
}
}
@keyframes move1{
0%{
margin-left:0%;
}
100%{;
margin-left:100%;
}
}
@keyframes move2{
from { transform: rotate(0deg) translateX:(150px) rotate:(0deg); }
to { transform: rotate(360deg) translateX(150px) rotate(-360deg); }
}
*{
-webkit-user-select: none; /* Chrome all / Safari all */
-moz-user-select: none; /* Firefox all */
-ms-user-select: none; /* IE 10+ */
user-select: none; /* Likely future */
font: 16px Georgia, sans serif;
}
#gameWrapper{
display:none;
}
#loadWrapper{
position: fixed;
top: 0;
left: 0;
width:100%;
height:100%;
}
.loaded{
/*Give Body background*/
background-image:url("ColorExplosion.jpg");
background-size:100% 100%;
animation:backgroundAnimate 5s linear infinite;
}
.loadScreen{
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
//border: 3px solid transparent;
border-top: 3px solid gold;
border-radius:75%;
animation:spin 2.5s ease-in-out infinite;
}
.loadScreen::before {
content: "";
position: absolute;
top: 5px;
left: 5px;
right: 5px;
bottom: 5px;
//border: 3px solid transparent;
border-bottom: 3px solid green;
border-radius:75%;
animation:spin 2.0s ease-in-out infinite alternate-reverse;
}
.loadScreen::after {
content: "";
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
border-left: 3px solid silver;
border-radius:75%;
animation:spin 1.5s ease-in-out infinite;
}
.loadText{
position:relative;
animation:move2 5s infinite;
}
.Tile{
height:50px;
width:50px;
margin:1px;
float:left;
box-shadow: .5 .5 .8 #000; /*Needs work*/
background-color:black;
text-align:center;
font: bold 30px Papyrus, serif;
background-blend-mode:luminosity;
}
.activeTile{
opacity:.78;
box-shadow: inset 0 0 0 5px white;
animation:spin 5.5s ease-in-out infinite;
transform:scale(1.1);
}
.pauseTile{
animation-play-state: paused;
}
#Board{
display:block;
height:520px;
width:520px;
background-image:url("FlameArtwork2.jpg");
background-size:100% 100%;
background-color:transparent;//#222200;
}
li{
display:inline-block;
list-style:none;
background-color:#DD3542;
height:35px;
width:170px;
line-height:35px;
text-align:center;
box-shadow: 1.4 1.4 1.6 #FF0;
}
#muteBtn{
background-color:green;
}
#inputCode{
display:inline-block;
}
.hovering{
display:none;
opacity:0;
}
li:hover .hovering{
display:inline;
float:left;
opacity:.7;
background-color:#DDA;
}
#brushesMenu{
display:none;
}
</style>
</head>
<body>
<noscript>
<style type="text/css">
#loadWrapper, #gameWrapper{
display:none;
}
noscript{
display:block;
}
</style>
<p>Your browser does not support javascript.</p>
</noscript>
<div id="loadWrapper">
<div id="loadText"></div>
<div class="loadScreen"></div>
</div>
<div id="gameWrapper">
<div id="ButtonBar"><ul id="mainMenu" class="menu">
<li id = "increaseBtn"><span id="increaseBtnText">IncrementValue</span><span class="hovering">Change the progression of colors.</span></li>
<li id = "brushesBtn"><span>Toggle Brushes</span><span class="hovering">Change Tile Selection Brush</span></li>
<li id = "upgradeBtn"><span>ALL</span><span class="hovering">Advance all tiles by a color.</span></li>
<li id = "lockBtn"><span>LOCK</span><span class="hovering">Stay at the current song until unlocked.</span></li>
<li id = "clearBtn"><span>CLEAR</span><span class="hovering">Reset all tiles to the default color.</span></li>
<li id = "muteBtn"><span id="MuteBtnText">Mute</span><span class="hovering">Mute all sounds. Tile progression will not change the soundtrack.</span></li>
<li id = "inputBtn"><input id="inputCode" type="text" value="0"><span id = "inputCodeText"class="hovering"></span></li>
</ul>
<ul id="brushesMenu" class="menu">
<!--li id = "backBtn"><span>Back to Menu</span><span class="hovering">Return to the main menu.</span></li>
<li id = "hoverBtn"><span id="hoverBtnText">HOVER: OFF</span><span class="hovering">Advance tiles through hovering.</span></li>
<li id = "crossBtn"><span id="crossBtnText">CROSS: OFF</span><span class="hovering">Advance tiles in a cross pattern.</span></li>
<li id = "rowBtn"><span id="rowBtnText">ROW: OFF</span><span class="hovering">Advance tiles in the same row.</span></li>
<li id = "colBtn"><span id="colBtnText">COLUMN: OFF</span><span class="hovering">Advance tiles in the same column.</span></li-->
</ul>
</div>
<div id="Board"></div>
<div id="ytplayer"></div>
</div>
<script type = "text/javascript">
//**************Initialization of LoadScreenText
var loadContent = ["Loading...","Blah1", "Blah2", "Blah3", "BLah4"];
var applyLoadContent = [];
for(let i = 0; i<loadContent.length; i++){
applyLoadContent.push("<span class='loadText'>"+loadContent[i]+"</span>");
}
$('#loadText').html(applyLoadContent.join(''));
//**************Initialization of Board
var board = [];
for(let i = 1; i<=100; i++){
board.push("<div class='Tile' draggable='false' data-id='"+i+"' data-state='"+0+"'></div>");
}
$('#Board').html(board.join(''));
var brushes = [{name:"hover", btnText:"HOVER: OFF", hoverText:"Advance tiles through hovering."},{name:"cross", btnText:"CROSS: OFF", hoverText:"Advance tiles in a cross pattern."},{name:"row", btnText:"ROW: OFF", hoverText:"Advance tiles in the same row."},{name:"col", btnText:"COLUMN: OFF", hoverText:"Advance tiles in the same column."},{name:"leftDiag", btnText:"LEFT DIAG: OFF", hoverText:"Advance tiles in the left diagonal."},{name:"rightDiag", btnText:"RIGHT DIAG: OFF", hoverText:"Advance tiles in the right diagonal."},{name:"knight", btnText:"KNIGHT: OFF", hoverText:"Advance tiles in Ls."}];
var backBtn = "<li id = 'backBtn'><span>Back to Menu</span><span class='hovering'>Return to the main menu.</span></li>";
var brushesMenu = [backBtn];
for(let i = 0; i<brushes.length;i++){
brushesMenu.push("<li id = '"+brushes[i].name+"Btn'><span id='"+brushes[i].name+"BtnText'>"+brushes[i].btnText+"</span><span class='hovering'>"+brushes[i].hoverText+"</span></li>");
}
$('#brushesMenu').html(brushesMenu.join('\
'));
//************** Initalization of global variables
var states = ["#000000", "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#FFFFFF",];//replaced!
var incrementValue = 1;
var activeTiles = [];
var lockSong = false;
//brushes
var hoverBrush = false;
var crossBrush = false;
var rowBrush = false;
var colBrush = false;
var leftDiagBrush = false;
var rightDiagBrush = false;
var knightBrush = false;
var brushes = [hoverBrush, crossBrush, rowBrush, colBrush, leftDiagBrush, rightDiagBrush, knightBrush];
//*************Color Generator
states = [];
function generateColors(){
var numStates = 5+50*Math.random();
while(numStates>0){
states.push('#' + ("000000" + Math.random().toString(16).slice(2, 8).toUpperCase()).slice(-6));
numStates--;
}
}
generateColors();
//**************** Youtube
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
var timeoutVar;//for timeouts
var mute = false;
var customlist = [];
var defaultlist = ["noneMROp_E8","xV6PsSUs5ow", "uIWUSd5O1L0", "0TmoYBcLul8", "l99uLeEVqp8", "tz82xbLvK_k", "c5daGZ96QGU", "62-DdZ_uM3k", "8VGI7PX8mic", "7BgAeFcTlA8", "EXNHXbpe1ac", "PeFhZMhN9Io", "w_QILPuvW-4", "_hH5MbSr734", "-zUayxi1Ono", "qonslJnjzWM", "4nXG4Cp-1RI", "Azxk0PgseyI", "nVhd16EzRic", "eFHdRkeEnpM", "OixZKhcq1fQ"];
var rwbylist = ["EczdC7_WxVQ","xmOZL_0rj70","If1jeIstbJs","JsValLyKX_E","siHx0Yo-mqE","Abf8CQ_dxzc","ili_HdPj8Ik","bUuoYqyLw_k","B5yY4aGqUsc","zDXgbdhj5Zc"];
var tsfh0 = ["LRLdhFVzqt4","R4Jf6r6BU2A","jIxas0a-KgM","6O6Q1OiF6LI","D4tF4R24t1g","pKv_wua6kFE"];
var tsfh1 = ["tGh4FcZKekA","2nKqerDrg7M","n-Dh3ftkRAs","RKmw9oS__MM","8VGI7PX8mic","PMPefT3IUZ8","QDMFwG8A5SU","I36GfCl_01A","rNdZu0A6Qks","bG2BEjDfh3I","w8GwTV1TAns","6tByGFY8WRY","SxThZpslbhE","6tByGFY8WRY","ZZ97crvBpzg","pICAha0nsb0",];//tsfh amaria/battlecry/illumina
var tsfh2 = ["Hcj7dVA8Mr8","WYNqrdOQ_p8","xW3MvrC2YcY","fbQrfB2kz94","5nBRdjXDRhw","yzQdbaeJ8IU"];
var consideration = ["6vCxBQy2SOk","CRd1sXmTcA0","6sZVZJOfIC8","mTdMWf3dOHo","KG7mgl6v41c","tZSogDCejlw","5EA0Zkgh__U","Xpzqox6LCcA"];
var ytlist = defaultlist; //current yt playlist
var underlist = ["QyPR77rg1to","c5daGZ96QGU","tz82xbLvK_k","mZRP7nQkfrM","IkOK8tdEsFY","x_P5smsopK0","5P8V4mP5RLg","EBhFHJMVfiI","hMa4hZQbrms","2TgO-tN5wAM","YZ3XjVVNagU","qrBB3_rFPjg","aWBtpBwzzdM","Zzo6L3wsf8c","zdeZwAk6ULE","N3epEVMNJdY","Zz1bfhtKsHM","tDuEWw648jo","wRUdj1WgwIE","8wSYwqbp4S4","B4qdpiad_Q0","yWjavxcGfqM","l3sJ79C1Zyo","brP9Q08kEfk","mwrUem9vM_A"];
var gothiclist = ["0lldiIo9VUg","xXjJiLBz0wU","ym_ya5Tj9Kk","AEfIT9ENnd0","sf8vHkVLrFA","1IW5etbddPo","DLyqSQhS6E0","9axgGQUMmaQ","BV5Snl8M5M0","dzXL9lycrh4","RUODWSb-mk4","lmQCWEVtAIk","W2iL5G2ROb0","5rEMsHGzgU4","edMhMzCux9s","bhFDdJsSylU","N8ArtfKc5QQ","3wkZfhbdF0A","DLdfiFdeGzI","lF0h1tXbecI","nrA-GJOPclg","Vjt88N78QCs","WG3ks2XBS_A","Flvq8eqpYgo","a6pfstI4A2A","qc2CE9Nu_ho"];
var pianolist = [/*"w1d5nnCZdqY","W5_xFH5wqKM","5YMNBBB3EuA","O0NrHzokiFw",*/"bEL2GTtNPKE","-YzWlxbg34Y",/*"TcEacpB5wFw",*/"WsPJWGhp9Ng",/*"XsTjI75uEUQ",*/"LJttZ_Zfiw0"];
var ytlists = [defaultlist,rwbylist,tsfh0,tsfh1,tsfh2,underlist,gothiclist,pianolist,customlist]; //list of yt playlists
function changeList(listID){
if(ytlist != ytlists[listID]&&!lockSong&&!mute){
ytlist = ytlists[listID];
$("#inputCodeText").text("Input a number between 0 and "+(ytlist.length-1) +" to select a song.");
changeID(-1);
}
}
function onYouTubeIframeAPIReady() {
player = new YT.Player('ytplayer', {
height: '1',
width: '0',
videoId: 'QLB6FbhKS6A',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'changeVideo' : changeVideo
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
function onPlayerStateChange(event) {
if (event.data === 0 && !mute) {
changeID(-1);
}
/*else{
window.clearTimeout(timeoutVar);
}*/
}
function stopVideo() {
player.stopVideo();
}
function changeVideo(){
//window.clearTimeout(timeoutVar);
//timeoutVar = window.setTimeout(changeID(-1), 10000000);
changeID(-1);
}
function changeID(IDNum){
if(!mute){
if(!lockSong){
if(IDNum<0||IDNum>=ytlist.length){
IDNum = parseInt(Math.random()*ytlist.length);
}
player.loadVideoById(ytlist[IDNum]);
player.playVideo();
$('#inputCode').val(IDNum);
}
else if(lockSong){
player.playVideo();
}
}
}
function tileLeft(tileNum){
if($.isNumeric(tileNum)&&(tileNum+9)%10!==0){
return tileNum-1;
}
return false;
}
function tileRight(tileNum){
if($.isNumeric(tileNum)&&tileNum%10!==0){
return tileNum+1;
}
return false;
}
function tileUp(tileNum){
if($.isNumeric(tileNum)&&tileNum>10){
return tileNum-10;
}
return false;
}
function tileDown(tileNum){
if($.isNumeric(tileNum)&&tileNum<91){
return tileNum+10;
}
return false;
}
function tileUpLeft(tileNum){
if(tileNum>10&&(tileNum+9)%10!==0)
return (tileUp(tileLeft(tileNum)));
return false;
}
function tileUpRight(tileNum){
if(tileNum>10&&tileNum%10!==0)
return (tileUp(tileRight(tileNum)));
return false;
}
function tileDownLeft(tileNum){
if(tileNum<91&&(tileNum+9)%10!==0)
return (tileDown(tileLeft(tileNum)));
return false;
}
function tileDownRight(tileNum){
if(tileNum<91&&tileNum%10!==0)
return (tileDown(tileRight(tileNum)));
return false;
}
//*************** Functions-- targetTile
function incrementState(targetTile){
targetTile.attr('data-state', parseInt(targetTile.attr('data-state'),10)+incrementValue);
while(targetTile.attr('data-state')>=states.length){
targetTile.attr('data-state', targetTile.attr('data-state')-states.length);
}
targetTile.css('background-color', states[targetTile.attr('data-state')]);
targetTile.text(targetTile.attr('data-state'));
}
//***************Functions-- Tile class
$('.Tile').mouseover(function(){
let centerID = parseInt($(this).attr('data-id')); //ID of tile currntly hovered over
function cross(targetTile){ /****************Begin with brush functions*/
let cross = [];
if(tileUp(centerID))
cross.push(tileUp(centerID));
if(tileDown(centerID))
cross.push(tileDown(centerID));
if(tileLeft(centerID))
cross.push(tileLeft(centerID));
if (tileRight(centerID))
cross.push(tileRight(centerID));
return cross;
}
function row(targetTile){
let row = [];
let looperID = centerID;
while(tileLeft(looperID)){
looperID--;
row.push(looperID);
}
looperID = centerID;
while(tileRight(looperID)){
looperID++;
row.push(looperID);
}
return row;
}
function column(targetTile){
let col = [];
let looperID = centerID;
while(tileUp(looperID)){
looperID-=10;
col.push(looperID);
}
looperID = centerID;
while(tileDown(looperID)){
looperID+=10;
col.push(looperID);
}
return col;
}
function leftDiag(targetTile){
let diag = [];
let looperID = centerID;
while(tileUpLeft(looperID)){
looperID-=11;
diag.push(looperID);
}
while(tileDownRight(looperID)){
looperID+=11;
diag.push(looperID);
}
return diag;
}
function rightDiag(targetTile){
let diag = [];
let looperID = centerID;
while(tileUpRight(looperID)){
looperID-=9;
diag.push(looperID);
}
while(tileDownLeft(looperID)){
looperID+=9;
diag.push(looperID);
}
return diag;
}
function knight(targetTile){
let knight = [];
let looperID = centerID;
let up = tileUp(tileUp(looperID));
let down = tileDown(tileDown(looperID));
let left = tileLeft(tileLeft(looperID));
let right = tileRight(tileRight(looperID));
if(up){
if(tileLeft(up))
knight.push(tileLeft(up));
if(tileRight(up))
knight.push(tileRight(up));
}
if(down){
if(tileLeft(down))
knight.push(tileLeft(down));
if(tileRight(down))
knight.push(tileRight(down));
}
if(left){
if(tileUp(left))
knight.push(tileUp(left));
if(tileDown(left))
knight.push(tileDown(left));
}
if(right){
if(tileUp(right))
knight.push(tileUp(right));
if(tileDown(right))
knight.push(tileDown(right));
}
return knight;
}
let oldTiles = activeTiles; //old Tiles were current active Tiles.
activeTiles = [parseInt($(this).attr('data-id'))]; //reset with only center Tile
//Brushes
if(crossBrush)
cross($(this)).forEach(function(arg){
activeTiles.push(arg);
});
if(colBrush){
column($(this)).forEach(function(arg){
activeTiles.push(arg);
});
}
if(rowBrush){
row($(this)).forEach(function(arg){
activeTiles.push(arg);
});
}
if(leftDiagBrush){
leftDiag($(this)).forEach(function(arg){
activeTiles.push(arg);
});
}
if(rightDiagBrush){
rightDiag($(this)).forEach(function(arg){
activeTiles.push(arg);
});
}
if(knightBrush){
knight($(this)).forEach(function(arg){
activeTiles.push(arg);
});
}
let activeTileSet = new Set(activeTiles); //set removes duplicates
activeTiles=[...activeTileSet].sort(function(a, b){return a-b;});//sort activeTiles by id
//alert("ActiveTiles: "+activeTiles);
//alert("Equality :"+(activeTiles.toString()==oldTiles.toString())+"old: "+oldTiles+" new: "+activeTiles);
function arrEquals(arr1, arr2){
if(arr1.length!=arr2.length){
return false;
}
for(let i = 0; i<arr1.length; i++){
if(arr1[i]!=arr2[i])
return false;
}
return true;
}
if(!arrEquals(oldTiles, activeTiles)){
oldTiles.forEach(function(arg){ // remove activeTile from the old active tiles
if(activeTiles.indexOf(arg)<0){
$(".Tile[data-id='"+arg+"']").removeClass("activeTile pauseTile");
}
});
activeTiles.forEach(function(arg){//add activeTile to the new active tiles
if(oldTiles.indexOf(arg)<0){
$(".Tile[data-id='"+arg+"']").addClass("activeTile");
if(mute){
$(".Tile[data-id='"+arg+"']").addClass("pauseTile");
}
}
});
}
let tempTiles = []; //for hoverbrush
let temp = -1;
if(hoverBrush){
oldTiles.forEach(function(arg){
let tempTile = activeTiles.indexOf(arg);
if(tempTile>-1){
tempTiles.push(arg);
activeTiles[tempTile] = temp; //do not change color of the old activetiles
temp--;
}
});
$(this).click();
for(let i = 0; i<tempTiles.length; i++){ //put the old active tiles back into the list
for(let j = 0; j<activeTiles.length; j++){
if(activeTiles[j]<0){
activeTiles[j] = tempTiles[i];
j+=activeTiles.length;//only fill in 1 tile
// alert("Temps: "+ tempTiles);
}
}
}
}
});
$('.Tile').click(function(){
activeTiles.forEach(function(arg){
if(arg!=-1)
incrementState($(".Tile[data-id='"+arg+"']"));
});
changeVideo();
//incrementState($(this));
});
//***************Functions-- Buttons
$('#increaseBtn').click(function(){
if(incrementValue+1>=states.length)
incrementValue=0;
incrementValue++;
$('#increaseBtnText').text("IncrementValue: "+ incrementValue + "/ " + (states.length-1));
});
$('#brushesBtn').click(function(){
$('.menu').hide();
$('#brushesMenu').show();
});
$('#backBtn').click(function(){
$('.menu').hide();
$('#mainMenu').show();
});
$('#hoverBtn').click(function(){
hoverBrush = !hoverBrush;
if(hoverBrush){
$('#hoverBtnText').text("HOVER: ON");
$(this).css('background-color', "green");
}
else{
$('#hoverBtnText').text("HOVER: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#crossBtn').click(function(){
crossBrush = !crossBrush;
if(crossBrush){
$('#crossBtnText').text("CROSS: ON");
$(this).css('background-color', "green");
}
else{
$('#crossBtnText').text("CROSS: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#rowBtn').click(function(){
rowBrush = !rowBrush;
if(rowBrush){
$('#rowBtnText').text("ROW: ON");
$(this).css('background-color', "green");
}
else{
$('#rowBtnText').text("ROW: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#colBtn').click(function(){
colBrush = !colBrush;
if(colBrush){
$('#colBtnText').text("COL: ON");
$(this).css('background-color', "green");
}
else{
$('#colBtnText').text("COL: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#leftDiagBtn').click(function(){
leftDiagBrush = !leftDiagBrush;
if(leftDiagBrush){
$('#leftDiagBtnText').text("LEFT DIAG: ON");
$(this).css('background-color', "green");
}
else{
$('#leftDiagBtnText').text("LEFT DIAG: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#rightDiagBtn').click(function(){
rightDiagBrush = !rightDiagBrush;
if(rightDiagBrush){
$('#rightDiagBtnText').text("RIGHT DIAG: ON");
$(this).css('background-color', "green");
}
else{
$('#rightDiagBtnText').text("RIGHT DIAG: OFF");
$(this).css('background-color', "#DD3542");
}
});
$('#knightBtn').click(function(){
knightBrush = !knightBrush;
if(knightBrush){
$('#knightBtnText').text("KNIGHT: ON");
$(this).css('background-color', "green");
}
else{
$('#knightBtnText').text("KNIGHT: OFF");
$(this).css('background-color', "#DD3542");
}
});
//brushes end
$('#clearBtn').click(function(){
$('.Tile').attr('data-state', 0);
$('.Tile').css('background-color', states[0]);
$('.Tile').text("");
activeTiles.forEach(function(arg){
$(".Tile[data-id='"+arg+"']").removeClass("activeTile");
});
activeTiles = [];
});
$('#upgradeBtn').click(function(){
let oldTiles = activeTiles;
activeTiles = [];
for(let i = 1;i<=100;i++){
activeTiles.push(i);
}
//alert(" tile id: "+ $('[data-id=0]').css('background-color');
$('.Tile[data-id='+ Math.floor(Math.random()*101)+']').click();
activeTiles = oldTiles;
});
$('#lockBtn').click(function(){
lockSong = !lockSong;
if(lockSong){
$(this).css('background-color', "green");
}
else{
$(this).css('background-color', "#DD3542");
}
});
$('#muteBtn').click(function(){
mute = !mute;
if(mute){
$(this).css('background-color', "#DD3542");
$("#muteBtnText").text("Sound");
player.pauseVideo();
activeTiles.forEach(function(arg){
$(".Tile[data-id='"+arg+"']").addClass("pauseTile");
});
}
else{
$(this).css('background-color', "green");
$("muteBtnText").text("Mute");
player.playVideo();
activeTiles.forEach(function(arg){
$(".Tile[data-id='"+arg+"']").removeClass("pauseTile");
});
}
});
$('#inputCode').bind('input',function(e){
if (window.event && event.propertyName != "value")
return;
//clearTimeout(timeoutVar);
var changeNum = $(this).val();
if($.isNumeric(changeNum)&&changeNum!=ytlist.indexOf(player.getVideoData()['video_id'])){
var num = parseInt(changeNum);
changeID(num);
}
if(changeNum.length == 11 && typeof changeNum === 'string' && !lockSong &&!mute){
player.loadVideoById(changeNum);
player.playVideo();
customlist.push(changeNum);
ytlist=customlist;
$('#inputCode').val(ytlist.indexOf(changeNum));
}
});
//**************Keypresses
$(document).ready(function(){
$(document).keyup(function(event){
//alert(event.which);
switch(event.which){
case 88://x clears the board
$('#clearBtn').click();
break;
case 73:// i = upgrades the board
$('#upgradeBtn').click();
break;
case 82://r = rwby
changeList(1);
break;
case 68://d = defaultlist
changeList(0);
break;
case 81://q = tsfh0 classics
changeList(2);
break;
case 87://w = tsfh1 amaria/battlecry/illumina
changeList(3);
break;
case 69://e = tsfh2
changeList(4);
break;
case 85:// u = undertale
changeList(5);
break;
case 71://g = gothic3
changeList(6);
break;
case 80://p = piano
changeList(7);
break;
}
});
//*************Initialize things
window.ondragstart = function() { return false; }
window.onload = function(){
//ytlist = ytlists[Math.floor(Math.random()*ytlists.length)];
changeList(Math.floor(Math.random()*(ytlists.length-1))); //-1 so we don't roll customlist
changeID(-1);
setTimeout(function(){
$("#loadWrapper").hide();
$('body').addClass('loaded');
$("#gameWrapper").show();
}, 10000);
};
$('#increaseBtnText').text("IncrementValue: "+ incrementValue + "/ " + (states.length-1));
$('#clearBtn').click();//initialize board color
$('#inputCode').val(1);//initialize increasebutton text
});
</script>
</body>
</html>