forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AAAAHHHHHHHHHHHH.js
298 lines (251 loc) 路 6.41 KB
/
AAAAHHHHHHHHHHHH.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
/*
@title: maze_game_starter
@author: Cheru Berhanu
@tags: []
@img: ""
@addedOn: 2023-08-08
*/
const moving = tune `
42.796005706134096: G5^42.796005706134096,
1326.676176890157`
const winTune = tune `
127.11864406779661: B4~127.11864406779661 + G4-127.11864406779661,
127.11864406779661: C5~127.11864406779661,
127.11864406779661: C5~127.11864406779661 + G4-127.11864406779661,
127.11864406779661: F5~127.11864406779661,
127.11864406779661: C5-127.11864406779661,
127.11864406779661: G5~127.11864406779661 + D5-127.11864406779661,
127.11864406779661: G5~127.11864406779661 + D5-127.11864406779661,
127.11864406779661,
127.11864406779661: F5~127.11864406779661,
127.11864406779661: E5~127.11864406779661 + B4-127.11864406779661,
127.11864406779661: B4-127.11864406779661,
127.11864406779661: D5~127.11864406779661,
127.11864406779661: D5~127.11864406779661,
127.11864406779661: B4-127.11864406779661,
127.11864406779661: F5~127.11864406779661,
127.11864406779661,
127.11864406779661: E5~127.11864406779661 + C5-127.11864406779661,
127.11864406779661: E5~127.11864406779661 + C5-127.11864406779661,
127.11864406779661: G5~127.11864406779661,
127.11864406779661,
127.11864406779661: G5~127.11864406779661 + E5-127.11864406779661,
127.11864406779661,
127.11864406779661: G5~127.11864406779661,
127.11864406779661: A5~127.11864406779661 + F5-127.11864406779661,
127.11864406779661: A5~127.11864406779661 + F5-127.11864406779661,
127.11864406779661,
127.11864406779661: G5~127.11864406779661 + A5-127.11864406779661,
127.11864406779661: G5~127.11864406779661,
508.47457627118644`
const youDied = tune `
55.45286506469501: C5~55.45286506469501,
55.45286506469501: B4~55.45286506469501,
55.45286506469501: A4~55.45286506469501,
55.45286506469501: A4~55.45286506469501,
1552.6802218114603`
const America = tune `
30000: B5-30000 + G5-30000 + F5-30000 + E5~30000 + C5~30000,
30000: A5-30000 + G5-30000 + B5-30000 + E5~30000 + C5~30000,
30000: F5-30000 + A5-30000 + G5-30000 + E5~30000 + C5~30000,
30000: F5-30000 + B5-30000 + A5-30000 + E5~30000 + C5~30000,
30000: F5-30000 + B5-30000 + G5-30000 + A5-30000 + E5~30000,
30000: F5-30000 + G5-30000 + B5-30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
30000: B5~30000 + G5~30000 + E5~30000 + C5~30000,
510000`
const player = "p"
const wall = "w"
const goal = "g"
const box = "b"
const wall2 = "a"
const wall3 = "c"
const cobwebs = "s"
setLegend(
[ player, bitmap`
................
.....1....1.....
.....1L..L1.....
.....1LLLL1.....
.....LLLLLL.....
.....0LLLL0.....
..LL.LL88LL.LL..
..1LL.LLLL.LL1..
...1LLLLLLLL11..
...11LL11LL11...
....11L11L11....
.....1L11L1.....
......L..L......
................
................
................` ],
[wall, bitmap `
.11111111LLLLLL.
..11L11111LLLL..
...1111111LLL...
...11L1111LL....
...1111111LL....
...1111111LL....
....111111L.....
....11111LL.....
.....111LLL.....
.....1111L......
.....111LL......
.....111L.......
......1L........
......1L........
......L.........
................`],
[goal, bitmap `
1L11111111111111
111111LLLLLL11L1
L11L1LL00000L11L
11LL1L0000000L1L
1111L00000000L11
1111L000000000L1
111L0000000000L1
111L0000000000L1
11LL0000000000L1
1L1L000000000L11
1111L00000000L1L
111110000000LL1L
11111L00000L111L
1LL11LLLLLL11LLL
11L1111111111L11
1111111111111111`],
[box, bitmap `
4444D4444444444D
4D444D..DD4444D4
44DDD.....DD4444
4D44.......DDD44
44D.........D444
4D..........D444
4D..........DD44
4D...........D4D
4D...........D44
4D...........D4D
4D...........DD4
DD...........DDD
D............DDD
D............DDD
D.............DD
D.............DD`],
[wall2, bitmap `
................
...........1....
...........1....
..........11....
...1......111.11
1.11.....11L1111
1111L...11111111
1L111111111111L1
L11L1111L111111L
LL1111111L1L1111
LLL11L1L111LL11L
LLL1LLL1111LLLLL
LLLL1LLL11LLL1LL
L1LLLLLLLLLLLL11
0L1LLLLLLL1LLLL0
00LLLLLLL0LL0000`],
[wall3, bitmap `
00LLLLLLLLLLLL00
LLL11L11LL1L1011
L11111111L11111L
LLL11111111111LL
LLLL11111110LLLL
LLCL11LL11L1LLLL
L00CL1LLLLLL1LLL
LLLLLLLLLLLLLLLL
LLLLLLLL000LLLLL
LLLLLLL000LLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLC
LLLLLLLLLLLLLC00`],
[cobwebs, bitmap `
................
................
......LLLLL.....
.....LL8L8LL....
...LLL82L28LLL..
..LL8L28L28L8LL.
..L88888L88828L.
..L828L888L888L.
..LL8L88888L8LL.
...LL8828882LL..
....L8288888L...
....LL88L88LL...
.....LLLLLLL....
.....LLLLLLL....
................
................`]
);
setSolids([ wall, player, box, wall2, wall3 ])
setPushables({
[player]: [box, player]
})
let level = 0
const levels = [
map`
..w.w.....w..
............p
g............
.............
aaaaaaaaaaaaa
ccccccccccccc`,
map `
..............................................
..............................................
.sssss.s..s..s.sssssssss.ssssssss..sssss.ssss.
...s...s..s..s...s..s.......s...s..s.s...s....
...s...ssss.s.s..s..s.......s...ssss.s...s....
...s...s..s.sss..s..ssss....s...s..s.s...ssss.
...s...s..s.s.s..s..s.......s...s..s.s......s.
.sssss.s..s.s.s..s..ssss....s...s..sssss.ssss.
..............................................
....................ss.ss.....................
....................sssss.....................
..........p..........sss......................
......................s......................g`
]
setMap(levels[level])
onInput("s", () => {
getFirst(player).y += 1
playTune(moving)
})
onInput("w", () => {
getFirst(player).y -= 1
playTune(moving)
})
onInput("d", () => {
getFirst(player).x += 1
playTune(moving)
})
onInput("a", () => {
getFirst(player).x -= 1
playTune(moving)
})
afterInput(() => {
// when player covers goal they move to next level
const targetNumber = tilesWith(goal).length;
const numberCovered = tilesWith(goal, player).length;
if (numberCovered === targetNumber) {
level = level + 1;
const currentLevel = levels[level];
if (currentLevel !== undefined) {
setMap(currentLevel);
} else {
addText("You made it home!", { y: 4, color: color`5` });
playTune(winTune);
}
}
});