-
Notifications
You must be signed in to change notification settings - Fork 0
/
Score_it.js
516 lines (489 loc) · 14.5 KB
/
Score_it.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
/*
First time? Check out the tutorial game:
https://sprig.hackclub.com/gallery/getting_started
@title: Score it
@author:
@tags: []
@addedOn: 2024-00-00
*/
const player = "p"
const goal_u = "u"
const goal_l = "l"
const goal_r = "r"
const green = "g"
const black = "b"
const obstacle = "o"
const level1 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggglurggggg
gggggggoggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level2 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggglurggggg
ggggggooggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level3 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggglurggggg
ggggggogggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level4 = map`
bbbbbbbbbbbbb
ggggggggggggg
gggluuuuurggg
gggogoooogggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level5 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggglurggggg
ggggggooggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level6 = map`
bbbbbbbbbbbbb
ggggggggggggg
gggluuuuurggg
gggogoooogggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level7 = map`
bbbbbbbbbbbbb
ggggggggggggg
gggluuuuurggg
gggoooooogggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level8 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggggggglurg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level9 = map`
bbbbbbbbbbbbb
ggggggggggggg
gluuuuuuuuurg
gogooooooogog
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const level10 = map`
bbbbbbbbbbbbb
ggggggggggggg
ggggggggggggl
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggggggggg
ggggggpgggggg
uuuuuuuuuuuuu`
const backgroundTune = tune`
153.0612244897959: B5-153.0612244897959 + C4~153.0612244897959 + F4^153.0612244897959,
153.0612244897959: G5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: F5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: G5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: G5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: E5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: D5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: D5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: C5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: E5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: D5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: C5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: E5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: F5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: G5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: F5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: F5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: E5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: B4-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: B4-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: C5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: A4-153.0612244897959 + G4-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: C5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: A4-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: E5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: D5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: B4-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: B4-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: C5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: E5-153.0612244897959 + E4/153.0612244897959,
153.0612244897959: F5-153.0612244897959 + C4~153.0612244897959,
153.0612244897959: B5-153.0612244897959 + C4~153.0612244897959 + F4^153.0612244897959`
const goalTune = tune`
130.43478260869566,
130.43478260869566: A4/130.43478260869566 + G4-130.43478260869566,
130.43478260869566: B4-130.43478260869566 + C5/130.43478260869566,
130.43478260869566: D5-130.43478260869566 + E5/130.43478260869566,
130.43478260869566: F5-130.43478260869566 + G5/130.43478260869566,
130.43478260869566,
130.43478260869566: G5-130.43478260869566 + A5/130.43478260869566,
130.43478260869566: G5-130.43478260869566 + A5/130.43478260869566,
3130.434782608696`
const bgTune = tune`
410.958904109589: B4~410.958904109589 + A4~410.958904109589 + G4~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: F4~410.958904109589 + E4~410.958904109589,
410.958904109589: B4~410.958904109589 + A4~410.958904109589 + G5/410.958904109589,
410.958904109589: D5~410.958904109589 + E5~410.958904109589 + F5~410.958904109589 + C4^410.958904109589,
410.958904109589: G4~410.958904109589 + F4~410.958904109589 + C4^410.958904109589,
410.958904109589: C5~410.958904109589 + B4~410.958904109589 + E5^410.958904109589,
410.958904109589: C5~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: F4~410.958904109589 + C4^410.958904109589,
410.958904109589: A4~410.958904109589 + G4~410.958904109589 + F4~410.958904109589 + G5/410.958904109589,
410.958904109589: F4~410.958904109589 + C4^410.958904109589,
410.958904109589: B4~410.958904109589 + E4~410.958904109589 + D4~410.958904109589 + C4^410.958904109589,
410.958904109589: F4~410.958904109589 + E5^410.958904109589,
410.958904109589: A4~410.958904109589 + G4~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: A4~410.958904109589 + B4~410.958904109589 + E4~410.958904109589 + D4~410.958904109589 + C4^410.958904109589,
410.958904109589: A4~410.958904109589 + G5/410.958904109589,
410.958904109589: A4~410.958904109589 + E5~410.958904109589 + D5~410.958904109589 + C4^410.958904109589,
410.958904109589: C4^410.958904109589,
410.958904109589: A4~410.958904109589 + B4~410.958904109589 + F4~410.958904109589 + E5^410.958904109589,
410.958904109589: F4~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: C4^410.958904109589,
410.958904109589: A4~410.958904109589 + G4~410.958904109589 + B4~410.958904109589 + G5/410.958904109589,
410.958904109589: A4~410.958904109589 + C4^410.958904109589,
410.958904109589: G4~410.958904109589 + C4^410.958904109589,
410.958904109589: B4~410.958904109589 + A4~410.958904109589 + E5^410.958904109589,
410.958904109589: D5~410.958904109589 + F4~410.958904109589 + G4~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: E4~410.958904109589 + C4^410.958904109589,
410.958904109589: D4~410.958904109589 + G5/410.958904109589,
410.958904109589: G4~410.958904109589 + B4~410.958904109589 + A4~410.958904109589 + C4^410.958904109589,
410.958904109589: D5~410.958904109589 + C4^410.958904109589 + E5^410.958904109589,
410.958904109589: A4~410.958904109589 + F4~410.958904109589 + E4~410.958904109589 + E5^410.958904109589,
410.958904109589: F5~410.958904109589 + E5~410.958904109589 + D5~410.958904109589 + C4^410.958904109589,
410.958904109589: A4~410.958904109589 + B4~410.958904109589 + G4~410.958904109589 + C4^410.958904109589 + G5/410.958904109589`
const winningTune = tune`
94.9367088607595: C4/94.9367088607595 + G4/94.9367088607595 + D5-94.9367088607595,
94.9367088607595: D4/94.9367088607595 + A4/94.9367088607595 + E5-94.9367088607595,
94.9367088607595: E4/94.9367088607595 + B4/94.9367088607595 + F5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: F4/94.9367088607595 + C5/94.9367088607595 + G5-94.9367088607595,
94.9367088607595: G4/94.9367088607595 + D5/94.9367088607595 + A5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: A4/94.9367088607595 + E5/94.9367088607595 + B5/94.9367088607595,
94.9367088607595: B4/94.9367088607595 + F5/94.9367088607595 + B5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: G5/94.9367088607595 + C5/94.9367088607595 + B5/94.9367088607595,
94.9367088607595: F5/94.9367088607595 + B4/94.9367088607595 + B5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: E5/94.9367088607595 + A4/94.9367088607595 + B5/94.9367088607595,
94.9367088607595: D5/94.9367088607595 + G4/94.9367088607595 + A5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: C5/94.9367088607595 + F4/94.9367088607595 + G5-94.9367088607595,
94.9367088607595: B4/94.9367088607595 + E4/94.9367088607595 + F5-94.9367088607595 + C4/94.9367088607595,
94.9367088607595: A4/94.9367088607595 + D4/94.9367088607595 + E5-94.9367088607595,
94.9367088607595: G4/94.9367088607595 + C4/94.9367088607595 + D5-94.9367088607595,
94.9367088607595: C5-94.9367088607595,
1518.987341772152`
const loseTune = tune`
153.0612244897959: E5^153.0612244897959,
153.0612244897959: D5~153.0612244897959,
153.0612244897959: C5^153.0612244897959,
153.0612244897959: B4~153.0612244897959,
153.0612244897959: G4^153.0612244897959,
153.0612244897959: F4~153.0612244897959,
153.0612244897959: E4^153.0612244897959,
153.0612244897959: D4~153.0612244897959,
153.0612244897959: C4^153.0612244897959,
3520.408163265306`
const introColor = color`5`
let currentmap = 1
let vainterval
let playback = playTune(backgroundTune, Infinity)
setLegend(
[player, bitmap`
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDD0000DDDDDD
DDDD00022000DDDD
DDDD00222000DDDD
DDD0020202200DDD
DDD0222000220DDD
DDD0222002020DDD
DDD0020202200DDD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DDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD`],
[obstacle, bitmap`
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDD0DDDDDDDD
DDDDDD090DDDDDDD
DDDDD09990DDDDDD
DDDD0999990DDDDD
DDD099999990DDDD
DD09999999990DDD
D0999999999990DD
011111116666660D
000000000000000D`],
[black, bitmap`
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000`]
)
setSolids([player, goal_u, goal_l, goal_r, obstacle, black])
let level = 0
const levels = [
map`
ggggggggggg
gggglurgggg
ggggggggggg
ggggggggggg
ggggggggggg
ggggggggggg
ggggggggggg
ggggggggggg
uuuuuuuuuuu`,
level1,
level2,
level3,
level4,
level5,
level6,
level7,
level8,
level9,
level10,
]
setMap(levels[1])
setPushables({
[player]: []
})
setBackground("g")
let movcon = 1
let ycon = 0
let turner = 0
let movinterval = 200
let FirstInput = 0
let finished = 0
let automover;
let levtext
let LostTxt
function checkPlayerCollision(obj) {
let obstacles = getAll(obj);
for (let obstacleSprite of obstacles) {
if (getFirst(player).x === obstacleSprite.x && getFirst(player).y === (obstacleSprite.y+1)) {
return 1;
}
}
return 0;
}
function changeLevel(levelnum){
setMap(levels[levelnum])
ycon = 0
movcon =1
turner =0
if(finished == 1||finished == 2){
currentmap = 1
movinterval = 200
playback = playTune(backgroundTune, Infinity)
}
else {currentmap += 1}
if(levelnum >= 5) {
movinterval = 90
}
vainterval = setInterval(mainfunc,movinterval)
clearText(levtext)
levtext = addText(("Lvl: " + currentmap), options = { x:0, y:0, color:color`9` })
}
function handleLost(){
LostTxt = addText("You Lost :(\n\nPress any key\nto go to the\nfirst level", options = { x:4, y:5, color:introColor })
finished = 2
}
function mainfunc(){
if (getFirst(player).x == 0) {
turner = 1;
} else if (getFirst(player).x == 12) { turner = 0; }
if (turner == 1) { getFirst(player).x += 1 * movcon; } else { getFirst(player).x -= 1 * movcon; }
if (movcon == 0) {
if (checkPlayerCollision(obstacle) == 1) {
console.log("nah you missed")
clearInterval(vainterval)
playback.end()
playTune(loseTune)
handleLost()
} else if (getFirst(player).y == 1) {
console.log("nah you missed")
clearInterval(vainterval)
playback.end()
playTune(loseTune)
handleLost()
}
if (checkPlayerCollision(goal_u) == 1 || checkPlayerCollision(goal_l) == 1 || checkPlayerCollision(goal_r) == 1) {
console.log("GOOOOOOAAAALL");
clearInterval(vainterval)
if(currentmap==10){
finishTxt = addText("Game Finished\n\nPress any key\nto go to the\nfirst level", options = { x:4, y:5, color:introColor })
finished =1
playback.end()
playTune(winningTune)
}else{
changeLevel(currentmap + 1)
playTune(goalTune)
}
}
}
}
introText = addText("Welcome to \n Score It\n\nThere are\n10 Levels\n\nPress any key\nto continue", options = { x:5, y:4, color:introColor })
function mover() { getFirst(player).y -= 1*ycon; }
onInput("w", () => {
if(FirstInput == 1){
movcon = 0
ycon = 1
if(!automover){automover = setInterval(mover, 80)}}
})
afterInput(() => {
if(FirstInput == 0){
FirstInput = 1
clearText(introText)
vainterval = setInterval(mainfunc,movinterval)
levtext = addText(("Lvl: " + currentmap), options = { x:0, y:0, color:color`9` })
}
if(finished == 1){
clearText(finishTxt)
clearInterval(automover)
automover = undefined
changeLevel(1)
finished =0
}
if(finished == 2){
clearText(LostTxt)
clearInterval(automover)
automover = undefined
changeLevel(1)
finished =0
}
}
)