forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman_Explode.js
8656 lines (8629 loc) · 139 KB
/
Hangman_Explode.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
/*
@title: Hangman Explode
@author: Frank Z
@tags: ['retro', 'puzzle', 'endless']
@addedOn: 2024-10-08
*/
/*
CONTROLS:
W and S to move to difficulty on the menu, WASD to move cursor to letters in the game
J to select, in menu and in game
L, a shortcut to go to the next word, you may also move the cursor and select the NEXT button
EASY has 7 fuses, meaning you will explode after 7 wrong letters
MEDIUM has 6
HARD has 5
You get points based on how many fuses you have left, 1 for each
The word list is at the bottom, it has 1891 words, I took the list from the Hangman on
Coolmathgames and cut out ones that were too long or had invalid characters, then I
cut it down more so it would actually work on the sprig (I think there's a list limit)
*/
const Cursor = "c";
const BGnormal = "b";
const BGgapMiddle = "m";
const BGgapLeft = "l";
const BGgapRight = "r";
const LetterEmpty = "-";
const NEXT1 = "q";
const NEXT2 = "w";
const CheckMark = "v";
const XMark = "x";
const Bomb = "t";
const ExplodeFrame1 = "!";
const ExplodeFrame2 = "@";
const ExplodeFrame3 = "#";
const Fuse = "f";
const FuseEnd = "e";
setLegend(
[Cursor, bitmap`
..6.66.66.66.6..
.6.6..6..6..6.6.
6..............6
.6............6.
6..............6
6..............6
.6............6.
6..............6
6..............6
.6............6.
6..............6
6..............6
.6............6.
6..............6
.6.6..6..6..6.6.
..6.66.66.66.6..`],
[BGnormal, bitmap`
LLLLLL11L111111L
LLLLL1LL11111111
1L1L111111111111
LLLLL11111111111
L1L1111111111111
1111111111111111
L111111111111111
1L1111111111111L
L1111111111111L1
11111111111111LL
111111111111111L
11111111111111L1
111111111111LLLL
11111111111L11LL
11111111L1LLLLLL
L11111LL11LL1LLL`],
[BGgapMiddle, bitmap`
LLLLLL11L111111L
LL0..........011
................
................
................
................
................
................
................
................
................
................
................
................
110..........0LL
L11111LL11LL1LLL`],
[BGgapLeft, bitmap`
LLLLLL11L111111L
LL0..........011
10..............
L...............
L...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
10..............
110..........0LL
L11111LL11LL1LLL`],
[BGgapRight, bitmap`
LLLLLL11L111111L
LL0..........011
..............01
...............1
...............1
...............1
...............1
...............1
...............1
...............1
...............L
...............L
...............1
..............0L
110..........0LL
L11111LL11LL1LLL`],
[LetterEmpty, bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..............1
L..............1
1..............1
L..............1
1..............L
1..............1
1..............L
1..............L
1..............1
1..............L
10..00000000..0L
110..........0LL
L111111L11LLLLLL`],
[NEXT1, bitmap`
LLLLLL11L111111L
LL0..........011
10..............
L...............
L...............
1..44..44.44444.
1..444.44.44....
1..444444.44....
1..444444.4444..
1..44.444.44....
1..44..44.44....
1..44..44.44444.
1...............
10..............
110..........0LL
L11111LL11LL1LLL`],
[NEXT2, bitmap`
LLLLLL11L111111L
LL0..........011
..............01
...............1
...............1
44..44.444444..1
44..44.444444..1
.4444....44....1
..44.....44....1
.4444....44....1
44..44...44....L
44..44...44....L
...............1
..............0L
110..........0LL
L11111LL11LL1LLL`],
[CheckMark, bitmap`
LL11444444441111
L144........4411
14..........D.41
14.........D4D41
4.........D444D4
4........D444D.4
4.......D444D..4
4..D...D444D...4
4.D4D.D444D....4
4D444D444D.....4
4.D44444D......4
4..D444D.......4
14..D4D.......41
14...D........41
1144........441L
11114444444411LL`],
[XMark, bitmap`
LL11333333331111
L133........3311
13............31
13..3......3..31
3..333....333..3
3...333..333...3
3....333333....3
3.....3333.....3
3.....3333.....3
3....333333....3
3...333..333...3
3..333....333..3
13..3......3..31
13............31
1133........331L
11113333333311LL`],
[Bomb, bitmap`
LLLLLL11L111111L
LLLLL11000001111
1L1L100000000011
LLL100000LL00011
L1L0000000LLL001
110000000000L001
L10000000000LL00
CC00000000000L00
CC00000000000000
1100000000000000
1100000000000000
11000L0000000000
11100LL00000000L
111100LLLL00000L
11111000000000LL
L11111L000001LLL`],
[ExplodeFrame1, bitmap`
LLLLLL11L111311L
LLLLL11000033111
1L1L103000030011
LLL300030L300011
L1L03303003LL003
110003009090L333
L100009999993L00
CC00000966000L00
CC33000066900000
1103339966993300
1100009990090330
11000L9090090033
111033L090030003
113300LL3L03000L
11311000303300LL
L11111L300301LLL`],
[ExplodeFrame2, bitmap`
LLLLLL11L311313L
LLLLL31003033331
1L1L133003030311
LLL3099999303311
33L03393363L3003
1330039060639933
L103309699693990
CC00936966600L00
CC33990666669933
1103396666963990
1103339660960330
33300L9366663033
1110333990093303
113303L93L09033L
113113099033003L
L11133L390301L3L`],
[ExplodeFrame3, bitmap`
L33LLL13L313313L
LL33L31303333331
131L333039339333
L333999999393331
33399366969L9003
1339669969636933
L109669699666990
3339966666603330
3C33996666669933
1103396666699990
1133339966999330
33303L9966999033
3113333999939903
113303L93L09393L
113113033033333L
L11133L39030133L`],
[Fuse, bitmap`
LLLLLL11L111111L
LL0..........011
................
................
................
................
.CC.........CCC.
CCCCC....CCCCCCC
C..CCCCCCCCC...C
.....CCCC.......
................
................
................
................
110..........0LL
L11111LL11LL1LLL`],
[FuseEnd, bitmap`
LLLLLL11L111111L
LL0..........011
................
................
................
................
...33.......CCC.
..3993...CCCCCCC
..3966CCCCCC...C
..3996CCC.......
...393..........
....3...........
................
................
110..........0LL
L11111LL11LL1LLL`],
["A", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L.....0000.....1
L....000000....1
1...000..000...1
L...00....00...1
1...00....00...L
1...00000000...1
1...00000000...L
1...00....00...L
1...00....00...1
1...00....00...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["B", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00000000....1
L..000000000...1
1..00.....000..1
L..00.....000..1
1..000000000...L
1..000000000...1
1..00.....000..L
1..00.....000..L
1..000000000...1
1..00000000....L
10............0L
110..........0LL
L111111L11LLLLLL`],
["C", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....0000000...1
L...000000000..1
1..000.....00..1
L..00..........1
1..00..........L
1..00..........1
1..00..........L
1..000.....00..L
1...000000000..1
1....0000000...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["D", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..0000000.....1
L..000000000...1
1..00....000...1
L..00.....000..1
1..00......00..L
1..00......00..1
1..00.....000..L
1..00....000...L
1..000000000...1
1..0000000.....L
10............0L
110..........0LL
L111111L11LLLLLL`],
["E", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..0000000000..1
L..0000000000..1
1..00..........1
L..00..........1
1..000000......L
1..000000......1
1..00..........L
1..00..........L
1..0000000000..1
1..0000000000..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["F", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...000000000..1
L...000000000..1
1...00.........1
L...00.........1
1...00000......L
1...00000......1
1...00.........L
1...00.........L
1...00.........1
1...00.........L
10............0L
110..........0LL
L111111L11LLLLLL`],
["G", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....0000000...1
L...000000000..1
1..000.....00..1
L..00..........1
1..00...0000...L
1..00...00000..1
1..00......00..L
1..000....000..L
1...000000000..1
1....0000000...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["H", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..00......00..1
1..00......00..1
L..00......00..1
1..0000000000..L
1..0000000000..1
1..00......00..L
1..00......00..L
1..00......00..1
1..00......00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["I", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...00000000...1
L...00000000...1
1......00......1
L......00......1
1......00......L
1......00......1
1......00......L
1......00......L
1...00000000...1
1...00000000...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["J", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....00000000..1
L....00000000..1
1.......00.....1
L.......00.....1
1.......00.....L
1.......00.....1
1...00..00.....L
1...00..00.....L
1...000000.....1
1....0000......L
10............0L
110..........0LL
L111111L11LLLLLL`],
["K", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...00....00...1
L...00...000...1
1...00..000....1
L...00.000.....1
1...00000......L
1...00000......1
1...00.000.....L
1...00..000....L
1...00...000...1
1...00....00...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["L", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...00.........1
L...00.........1
1...00.........1
L...00.........1
1...00.........L
1...00.........1
1...00.........L
1...00.........L
1...00000000...1
1...00000000...L
10............0L
110..........0LL
L111111L11LLLLLL`],
["M", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..000....000..1
1..0000..0000..1
L..0000000000..1
1..00.0000.00..L
1..00..00..00..1
1..00......00..L
1..00......00..L
1..00......00..1
1..00......00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["N", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..000.....00..1
1..0000....00..1
L..00000...00..1
1..00.000..00..L
1..00..000.00..1
1..00...00000..L
1..00....0000..L
1..00.....000..1
1..00......00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["O", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....000000....1
L...00000000...1
1..000....000..1
L..00......00..1
1..00......00..L
1..00......00..1
1..00......00..L
1..000....000..L
1...00000000...1
1....000000....L
10............0L
110..........0LL
L111111L11LLLLLL`],
["P", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...0000000....1
L...00000000...1
1...00....000..1
L...00....000..1
1...00000000...L
1...0000000....1
1...00.........L
1...00.........L
1...00.........1
1...00.........L
10............0L
110..........0LL
L111111L11LLLLLL`],
["Q", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....000000....1
L...00000000...1
1..000....000..1
L..00......00..1
1..00..00..00..L
1..00..000.00..1
1..00...00000..L
1..000...000...L
1...000000000..1
1....00000.00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["R", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L...0000000....1
L...00000000...1
1...00....000..1
L...00....000..1
1...00000000...L
1...0000000....1
1...00..000....L
1...00...000...L
1...00....000..1
1...00.....00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["S", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L....00000000..1
L...000000000..1
1..000.........1
L..000.........1
1...0000000....L
1....0000000...1
1.........000..L
1.........000..L
1..000000000...1
1..00000000....L
10............0L
110..........0LL
L111111L11LLLLLL`],
["T", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..0000000000..1
L..0000000000..1
1......00......1
L......00......1
1......00......L
1......00......1
1......00......L
1......00......L
1......00......1
1......00......L
10............0L
110..........0LL
L111111L11LLLLLL`],
["U", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..00......00..1
1..00......00..1
L..00......00..1
1..00......00..L
1..00......00..1
1..00......00..L
1..000....000..L
1...00000000...1
1....000000....L
10............0L
110..........0LL
L111111L11LLLLLL`],
["V", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..00......00..1
1..000....000..1
L...00....00...1
1...000..000...L
1....00..00....1
1....000000....L
1.....0000.....L
1.....0000.....1
1......00......L
10............0L
110..........0LL
L111111L11LLLLLL`],
["W", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..00......00..1
1..00......00..1
L..00......00..1
1..00..00..00..L
1..00.0000.00..1
1..0000000000..L
1..0000..0000..L
1..000....000..1
1..00......00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["X", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..000....000..1
1...000..000...1
L....000000....1
1.....0000.....L
1.....0000.....1
1....000000....L
1...000..000...L
1..000....000..1
1..00......00..L
10............0L
110..........0LL
L111111L11LLLLLL`],
["Y", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..00......00..1
L..000....000..1
1...000..000...1
L....000000....1
1.....0000.....L
1......00......1
1......00......L
1......00......L
1......00......1
1......00......L
10............0L
110..........0LL
L111111L11LLLLLL`],
["Z", bitmap`
LLLLLL11L111111L
LL0..........011
10............01
L..0000000000..1
L..0000000000..1
1........000...1
L.......000....1
1......000.....L
1.....000......1
1....000.......L
1...000........L
1..0000000000..1
1..0000000000..L
10............0L
110..........0LL
L111111L11LLLLLL`]
);
let wrongletters = 0;
let animationInterval;
let word = "";
let hint = "";
let correctletters = 0;
let wordfinished = false;
let secondwordlength = 0;
let points = 0;
let difficulty = "";
let level = 0;
const levels = [
map`
bbbbbbbbbb
#HANGMAN##
##EXPLODE#
bbbbbbbbbb
b-J-bEASYb
bSELbMEDbb
bECTbHARDb
bbbbbbbbbb`,
map`
bl.......b
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb
ABCDEFGHIJ
KLMNOPQRbb
STUVWXYZqw`
];
setMap(levels[level]);
addSprite(5, 4, Cursor);
//Set controls and limits movement for the cursor on the menu and in game
onInput("w", () => {
if (level === 0) {
if(getFirst(Cursor).y > 4) getFirst(Cursor).y -= 1;
};
if (level === 1) {
if(getFirst(Cursor).y > 5) getFirst(Cursor).y -= 1;
};
});
onInput("a", () => {
if (level === 1) {
if(getFirst(Cursor).x > 0) getFirst(Cursor).x -= 1;
};
});
onInput("s", () => {
if (level === 0) {
if(getFirst(Cursor).y < 6) getFirst(Cursor).y += 1;
};
if (level === 1) {
if(getFirst(Cursor).y < 7) getFirst(Cursor).y += 1;
};
});
onInput("d", () => {
if (level === 1) {
if(getFirst(Cursor).x < 9) getFirst(Cursor).x += 1;
};
});
onInput("j", () => {
if (level === 0) {
pickdifficulty();
startgame();
}
else if (level === 1) {
submitletter();
};
});
onInput("l", () => {
if (level === 1) {
nextbutton();
};
});
//set the difficulty
function pickdifficulty() {
difficulty = 11 - getFirst(Cursor).y;
};
//spawn all items and text
function startgame() {
level += 1;
setMap(levels[level]);
spawnfuse();
addSprite(0, 5, Cursor);
setword();
updatetext();
};
//spawn fuses based on difficulty selected
function spawnfuse() {
for (let tile = 1; tile < 8 ; tile++) {
clearTile(tile, 0);
};
addSprite(1, 0, BGgapLeft);
addSprite(2, 0, BGgapMiddle);
addSprite(8 - difficulty, 0, FuseEnd);
for (let fuseX = 9 - difficulty; fuseX < 8 ; fuseX++) {
addSprite(fuseX, 0, Fuse);
};
addSprite(8, 0, Bomb);
};
//shorten the fuse, if it goes all thr way down, explode the bomb
function burnfuse() {
wrongletters += 1;
if (wrongletters < difficulty) {
let FuseEndX = getFirst(FuseEnd).x;
clearTile(FuseEndX, 0);
if (difficulty === 7 && wrongletters === 1) {
addSprite(FuseEndX, 0, BGgapLeft);
} else {
addSprite(FuseEndX, 0, BGgapMiddle);
};
clearTile(FuseEndX + 1, 0);
addSprite(FuseEndX + 1, 0, BGgapMiddle);
addSprite(FuseEndX + 1, 0, FuseEnd);
} else {
clearTile(7, 0);
addSprite(7, 0, BGgapMiddle);
explode(ExplodeFrames);
wordfinished = true;
};
};
//animation for the bomb exploding
let ExplodeFrames = [ExplodeFrame1, ExplodeFrame2, ExplodeFrame3];
function explode(animationlist) {
let frame = 0;
animationInterval = setInterval(function(){
clearTile(8, 0);
addSprite(8, 0, animationlist[frame]);
if (frame < animationlist.length - 1) {
frame += 1;
} else {
clearInterval(animationInterval);
points = 0;
addText("You Exploded", {x: 2, y: 9, color: color`3`});
revealletters();
};
}, 100);
};
//add sprites in letter positions to reveal the word
function revealletters() {
for (let letter = 0; letter < word.split(" ")[0].length; letter++) {
let selectedsprite = word.split(" ")[0][letter].toUpperCase();
clearTile(letter + 1, 2);
addSprite(letter + 1, 2, selectedsprite);
};
if (word.split(" ")[1]) {
for (let letter = 0; letter < word.split(" ")[1].length; letter++) {
let selectedsprite = word.split(" ")[1][letter].toUpperCase();
clearTile(letter + 1, 3);
addSprite(letter + 1, 3, selectedsprite);
};
};
};
//set the word to a random item in the list and place the blank sprites on the needed tiles
function setword() {
let randomitemindex = Math.floor(Math.random() * WordList.length);
word = WordList[randomitemindex]["word"];
hint = WordList[randomitemindex]["hint"];
console.log(word);
let wordlength1 = word.split(" ")[0].length;
for (let tileX = 1; tileX <= wordlength1; tileX++) {
clearTile(tileX, 2);
addSprite(tileX, 2, LetterEmpty);
};
if (word.split(" ")[1]) {
let wordlength2 = word.split(" ")[1].length;
for (let tileX = 1; tileX <= wordlength2; tileX++) {
clearTile(tileX, 3);
addSprite(tileX, 3, LetterEmpty);
};
};
};
//print the hint above the empty tiles,
//but some are too long so I had manually make them each go on two lines
function printhint() {
if (hint === "No Repeating Letters") {
addText(hint.slice(0, 13), {x: 2, y: 2, color: color`6`});
addText(hint.slice(13), {x: 2, y: 3, color: color`6`});
} else if (hint === "Official Crayon Colors") {
addText(hint.slice(0, 16), {x: 2, y: 2, color: color`6`});
addText(hint.slice(16), {x: 2, y: 3, color: color`6`});
} else if (hint === "Great Vocab Words") {
addText(hint.slice(0, 12), {x: 2, y: 2, color: color`6`});
addText(hint.slice(12), {x: 2, y: 3, color: color`6`});
} else if (hint === "Stars of Stage & Screen") {
addText(hint.slice(0, 15), {x: 2, y: 2, color: color`6`});
addText(hint.slice(15), {x: 2, y: 3, color: color`6`});
} else if (hint === "Fictional Characters") {
addText(hint.slice(0, 10), {x: 2, y: 2, color: color`6`});
addText(hint.slice(10), {x: 2, y: 3, color: color`6`});
} else if (hint === "Desserts & Sweets") {
addText(hint.slice(0, 9), {x: 2, y: 2, color: color`6`});
addText(hint.slice(9), {x: 2, y: 3, color: color`6`});
} else if (hint === "Gems, Rocks & Crystals") {
addText(hint.slice(0, 12), {x: 2, y: 2, color: color`6`});
addText(hint.slice(12), {x: 2, y: 3, color: color`6`});
} else if (hint === "Old-Fashioned Things") {
addText(hint.slice(0, 14), {x: 2, y: 2, color: color`6`});
addText(hint.slice(14), {x: 2, y: 3, color: color`6`});
} else if (hint === "Figures of Speech") {
addText(hint.slice(0, 11), {x: 2, y: 2, color: color`6`});
addText(hint.slice(11), {x: 2, y: 3, color: color`6`});
} else {
addText(hint, {x: 2, y: 3, color: color`6`});
};
};
//submit the letter selected or go to next word if conditions fit
function submitletter() {
//check if cursor is on NEXT button to go to next word
if (getFirst(Cursor).y === 7 && (getFirst(Cursor).x === 8 || getFirst(Cursor).x === 9)) {
nextbutton();
//check if cursor is on the empty tiles in the possible area the cursor can go
} else if (getFirst(Cursor).y === 6 && (getFirst(Cursor).x === 8 || getFirst(Cursor).x === 9)) {
//nothing, empty tiles
} else {
//check if the letter the cursor is on has a check or X already or if the word is already finished
if (getTile(getFirst(Cursor).x, getFirst(Cursor).y)[1].type !== "x" && getTile(getFirst(Cursor).x, getFirst(Cursor).y)[1].type !== "v" && wordfinished === false) {
let selectedsprite = getTile(getFirst(Cursor).x, getFirst(Cursor).y)[1].type;
let selectedletter = selectedsprite.toLowerCase();
if (word.includes(selectedletter)) {
//check for the letter is the first word of the word and show the sprites if letter is correct
for (let letter = 0; letter < word.split(" ")[0].length; letter++) {
if (word.split(" ")[0][letter] === selectedletter) {
clearTile(letter + 1, 2);
addSprite(letter + 1, 2, selectedsprite);
correctletters += 1;
};
};
//check if there is a second word then do the same as the first word
if (word.split(" ")[1]) {
for (let letter = 0; letter < word.split(" ")[1].length; letter++) {