forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusic!.js
581 lines (536 loc) · 12.6 KB
/
Music!.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
/*
@title: Music!
@author: Akeell
@tags: []
@addedOn: 2022-10-16
*/
/*
Intrustions:
This is a fun and simple game!
All you need to do it make music using the coloured keys.
The bright colours are higher keys and the grey colours are the same sound,
just lower.
The colourful pink and purple blocks are pre-written songs, so try them out.
Controls:
Use W, A, S, D to move
Use I, J, K, L for extra combined notes
*/
const player = "p";
const music1 = "a";
const music2 = "b";
const music3 = "r";
const music4 = "d";
const music5 = "e";
const music6 = "f";
const music7 = "g";
const music8 = "h";
const wall = "w";
const letter1 = "m";
const letter2 = "u";
const letter3 = "s";
const letter4 = "i";
const letter5 = "c";
const letter6 = "!";
const song1 = "v";
const song2 = "n";
const melody = tune`
138.88888888888889: g5~138.88888888888889 + e5~138.88888888888889 + g4~138.88888888888889 + c4~138.88888888888889,
4305.555555555556`;
const melody2 = tune`
193.5483870967742: g5-193.5483870967742 + d5-193.5483870967742 + c4-193.5483870967742 + g4-193.5483870967742,
6000`;
const melody3 = tune`
200: g5/200 + g4/200 + c4/200 + d5/200,
6200`;
const melody4 = tune`
192.30769230769232: g5^192.30769230769232 + d5^192.30769230769232 + g4^192.30769230769232 + c4^192.30769230769232,
5961.538461538462`;
const melody5 = tune`
198.67549668874173: f4~198.67549668874173 + a4~198.67549668874173 + c4~198.67549668874173,
6158.940397350993`;
const melody6 = tune`
196.07843137254903: a4-196.07843137254903 + f4-196.07843137254903 + c4-196.07843137254903,
6078.43137254902`;
const melody7 = tune`
198.67549668874173: a4/198.67549668874173 + f4/198.67549668874173 + c4/198.67549668874173,
6158.940397350993`;
const melody8 = tune`
193.5483870967742: a4^193.5483870967742 + f4^193.5483870967742 + c4^193.5483870967742,
6000`;
const melody9 = tune`
187.5: b5~187.5 + f5-187.5 + b4/187.5 + f4^187.5 + c4~187.5,
5812.5`;
const melody10 = tune`
184.04907975460122: f5~184.04907975460122 + b4~184.04907975460122 + d5-184.04907975460122 + e4/184.04907975460122 + c4^184.04907975460122,
5705.521472392638`;
const melody11 = tune`
205.4794520547945: a5-205.4794520547945 + c4-205.4794520547945 + c5^205.4794520547945 + g4~205.4794520547945 + f5/205.4794520547945,
6369.863013698629`;
const melody12 = tune`
202.7027027027027: b5^202.7027027027027 + c5^202.7027027027027 + c4~202.7027027027027 + g4-202.7027027027027 + f5/202.7027027027027,
6283.783783783784`;
const melody1 = tune`
161.29032258064515: f5~161.29032258064515,
161.29032258064515,
161.29032258064515: c5~161.29032258064515,
161.29032258064515,
161.29032258064515: f5~161.29032258064515,
161.29032258064515,
161.29032258064515: c5~161.29032258064515,
161.29032258064515,
161.29032258064515: f5~161.29032258064515,
161.29032258064515,
161.29032258064515: c5~161.29032258064515,
161.29032258064515,
161.29032258064515: e4^161.29032258064515 + g5/161.29032258064515,
161.29032258064515: e5-161.29032258064515,
161.29032258064515: e4^161.29032258064515,
161.29032258064515: e5-161.29032258064515,
161.29032258064515: e4^161.29032258064515,
161.29032258064515: e5-161.29032258064515,
161.29032258064515: e4^161.29032258064515,
161.29032258064515: e5-161.29032258064515,
161.29032258064515: e4^161.29032258064515 + g5/161.29032258064515,
161.29032258064515: d5/161.29032258064515,
161.29032258064515,
161.29032258064515: g4/161.29032258064515 + c5~161.29032258064515,
161.29032258064515,
161.29032258064515: e4/161.29032258064515 + a4~161.29032258064515,
161.29032258064515,
161.29032258064515: g4/161.29032258064515 + c5~161.29032258064515,
161.29032258064515,
161.29032258064515: e4/161.29032258064515 + a4~161.29032258064515,
161.29032258064515: g4/161.29032258064515 + c5~161.29032258064515,
161.29032258064515`;
const melody14 = tune`
161.29032258064515,
161.29032258064515: a5-161.29032258064515,
161.29032258064515,
161.29032258064515: g5-161.29032258064515,
161.29032258064515,
161.29032258064515: e5-161.29032258064515,
161.29032258064515,
161.29032258064515: c4-161.29032258064515,
161.29032258064515: a4/161.29032258064515,
161.29032258064515: f4/161.29032258064515,
161.29032258064515: c5/161.29032258064515,
322.5806451612903,
161.29032258064515: g4/161.29032258064515,
161.29032258064515: e5/161.29032258064515,
161.29032258064515: b4/161.29032258064515,
161.29032258064515: e5/161.29032258064515,
161.29032258064515,
161.29032258064515: g4/161.29032258064515,
161.29032258064515: c5~161.29032258064515,
161.29032258064515: c5~161.29032258064515 + d4^161.29032258064515,
161.29032258064515: c5~161.29032258064515,
161.29032258064515: c5~161.29032258064515 + d4^161.29032258064515,
322.5806451612903,
161.29032258064515: d4^161.29032258064515,
161.29032258064515: g4^161.29032258064515 + e5^161.29032258064515,
161.29032258064515: b4/161.29032258064515,
161.29032258064515: a4/161.29032258064515,
161.29032258064515: g4/161.29032258064515,
161.29032258064515: a4/161.29032258064515,
161.29032258064515: b4/161.29032258064515`;
setLegend(
[ player, bitmap`
................
................
................
....FFFFFFF.....
....F.....F.....
....F.0.0.F.....
....F.....F.....
....FFFFFFF.....
.......F........
.......F........
...FFFFFFFFF....
.......F........
.......F........
......F.F.......
.....F...F......
....F.....F.....`],
[ music1, bitmap`
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333
3333333333333333`],
[ music2, bitmap`
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777`],
[ music3, bitmap`
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999
9999999999999999`],
[ music4, bitmap`
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444
4444444444444444`],
[ music5, bitmap`
LLLLLLLLLLLLLLLL
L3LLLL3LLLLLLLLL
LLLLLLLLLLLL3LLL
LL3LLLLLLLLLLLLL
LLLLL3LL3LLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLL3LLL
LLL3LLL3LLLLLLLL
LLLLLLLLLLLLLLLL
3LLLLLLLLLLLLLLL
LLL3LLLL3LLL3LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLL3L
LLLLL3LLLLLLLLLL
LLLLLLLLL3LLLLLL
L3LLLLLLLLLLLLLL`],
[ music6, bitmap`
LLLLLLLLLLLLLLLL
LLLLLL7LLLLLLLLL
LL7LLLLLLLLLL7LL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLL7LLLL7LLLL
LL7LLLLLLLLLLLL7
LLLLLLLLLLLLLLLL
LLLLLLLLLL7LLLLL
LLLLLLLLLLLLLLLL
L7LLLL7LLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLL7LL7L
LL7LLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLL7LLLLL`],
[ music7, bitmap`
LLLLLLLLLLLLLLLL
L9LLLLL9LLLLLLLL
LLLLLLLLLLLLLL9L
LLLL9LLLLLLLLLLL
LLLLLLLLL9LLLLLL
LL9LLLLLLLLLLLLL
LLLLLLLLLLLLL9LL
LLLLLL9L9LLLLLLL
LLLLLLLLLLLLLLLL
L9LLLLL9LLLLLLLL
LLLLLLLLLLLLLL9L
LLLLLLLLLLL9LLLL
9LLLL9LLLLLLLLLL
LLLLLLLLLLLLLLLL
L9LLLLLLLL9LLLL9
LLLLL9LLLLLLLLLL`],
[ music8, bitmap`
LLLLLLL4LLLLLLLL
L4LLLLLLLLLLL4LL
LLL4LLLLLLLLLLLL
LLLLLLLLL4LLLLLL
LLLLLLLLLLLLL4LL
LL4LLLLLLLLLLLLL
LLLLLLLLLLLLLL4L
LLLLLLL4LLLLLLLL
LLLLLLLLLLLLLLLL
L4LL4LLLLLLLLLLL
LLLLLLLLLLL4LL4L
LLLLLLL4LLLLLLLL
LLLL4LLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLL4LLL4LL
4LLLLLLLLLLLLLLL`],
[ wall, bitmap`
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000`],
[ letter1, bitmap`
1..............1
11.............1
1.1...........11
1..1.........1.1
1...1.......1..1
1....1.....1...1
1.....1...1....1
1......1.1.....1
1.......1......1
1..............1
1..............1
1..............1
1..............1
1..............1
1..............1
1..............1`],
[ letter2, bitmap`
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.1............1.
.11111111111111.`],
[ letter3, bitmap`
1111111111111111
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1111111111111111
...............1
...............1
...............1
...............1
...............1
...............1
1111111111111111`],
[ letter4, bitmap`
.11111111111111.
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.......1........
.11111111111111.`],
[ letter5, bitmap`
1111111111111111
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1...............
1111111111111111`],
[ letter6, bitmap`
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
...1....1....1..
................
...1....1....1..`],
[ song1, bitmap`
HHHHHHHH4HHHHHHH
H7HH3HHHHH3HH7HH
4H6HHHH9HHHHH6HH
HHH9H7HHHHHHHHH4
H3HHHH6HH9H6HHHH
H4HHHHHHHHHHHH9H
HHHH3H4HHHHH4HHH
H6HH4HHH3H9HH3HH
HHH7HH9HHHHHH7HH
HHHHHHHHH7HHHHHH
H3H9HHH6HH4HHHH3
HHHHH3HHHHHH6HHH
7HHHHHHHHHHHHHHH
HH6H9HH4HH7HHHHH
HHH4HHHH3HH9HH6H
9HHHHHHHHHHHHHHH`],
[ song2, bitmap`
8888888888888888
8387868488888898
8888888889867888
8898488388888888
8688888884883887
8888869888898888
8883888848887868
8488888888388888
8888886888888848
8388988884886888
8887888888888883
8888868838987888
7868888888888888
8888884878888688
8889878888388889
8388888688888388`],
);
setSolids([wall, player]);
let level = 0;
const levels = [
map`
wabrdw
n....v
music!
..p...
wefghw`,
];
setMap(levels[level]);
setPushables({
[ player ]: [],
});
//Start - Movement
onInput("w", () => {
getFirst(player).y += -1;
});
onInput("s", () => {
getFirst(player).y += 1;
});
onInput("d", () => {
getFirst(player).x += 1;
});
onInput("a", () => {
getFirst(player).x += -1;
});
//End - Movement
//Extra notes
onInput("i", () => {
playTune(melody9)
});
onInput("k", () => {
playTune(melody10)
});
onInput("j", () => {
playTune(melody11)
});
onInput("l", () => {
playTune(melody12)
});
afterInput(() => {
const targetNumber = tilesWith(music1).length;
const numberCovered = tilesWith(music1, player).length;
const targetNumber2 = tilesWith(music2).length;
const numberCovered2 = tilesWith(music2, player).length;
const targetNumber3 = tilesWith(music3).length;
const numberCovered3 = tilesWith(music3, player).length;
const targetNumber4 = tilesWith(music4).length;
const numberCovered4 = tilesWith(music4, player).length;
const targetNumber5 = tilesWith(music5).length;
const numberCovered5 = tilesWith(music5, player).length;
const targetNumber6 = tilesWith(music6).length;
const numberCovered6 = tilesWith(music6, player).length;
const targetNumber7 = tilesWith(music7).length;
const numberCovered7 = tilesWith(music7, player).length;
const targetNumber8 = tilesWith(music8).length;
const numberCovered8 = tilesWith(music8, player).length;
const targetNumber9 = tilesWith(song1).length;
const numberCovered9 = tilesWith(song1, player).length;
const targetNumber10 = tilesWith(song2).length;
const numberCovered10 = tilesWith(song2, player).length;
if (numberCovered === targetNumber) {
playTune(melody);
}
if (numberCovered2 === targetNumber2) {
playTune(melody2);
}
if (numberCovered3 === targetNumber3) {
playTune(melody3);
}
if (numberCovered4 === targetNumber4) {
playTune(melody4);
}
if (numberCovered5 === targetNumber5) {
playTune(melody5);
}
if (numberCovered6 === targetNumber6) {
playTune(melody6);
}
if (numberCovered7 === targetNumber7) {
playTune(melody7);
}
if (numberCovered8 === targetNumber8) {
playTune(melody8);
}
if (numberCovered9 === targetNumber9) {
playTune(melody1);
}
if (numberCovered10 === targetNumber10) {
playTune(melody14);
}
});