-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ts
1026 lines (1026 loc) · 74.1 KB
/
main.ts
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
namespace SpriteKind {
export const NPC = SpriteKind.create()
export const Map = SpriteKind.create()
export const SurvivedPlayer = SpriteKind.create()
export const SurvivedNPC = SpriteKind.create()
}
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_game) {
timer.debounce("change_dark_mode", 500, function () {
dark_mode = !(dark_mode)
if (dark_mode) {
blockSettings.writeNumber("dark_mode", 1)
} else {
blockSettings.writeNumber("dark_mode", 0)
}
color.startFade(color.originalPalette, color.Black, 250)
color.pauseUntilFadeDone()
multilights.toggleLighting(dark_mode)
color.startFade(color.Black, color.originalPalette, 250)
color.pauseUntilFadeDone()
})
}
})
function summon_fish (ai: boolean, force_animate: boolean) {
left_fish_animations = [[img`
. . . . . . . . . . . . . . . .
. . . . . . . . c c c c c . . .
. . . . . . c c 5 5 5 5 5 c . .
. . . . . c 5 5 5 5 5 5 5 5 c .
. . . . c b b b b b b 5 5 5 c .
. . . . c 1 1 b b 1 b b c c . .
. . . c 1 1 1 b b 1 1 1 c . . .
. . . c 1 1 1 1 b 1 1 1 c . c c
. . . c d 1 1 1 b 1 1 1 b b 5 c
. . c c d 1 c 1 b 1 b 1 5 5 5 c
. c c d d 1 1 1 1 1 b 1 b b 5 c
f d d d 1 1 1 1 1 b b 1 f . c c
f f f 1 1 1 1 1 1 b b b f . . .
. . . f f 1 1 1 b b b 5 5 f . .
. . . . . f f f 5 5 5 5 5 f . .
. . . . . . . . f f f f f f . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . . . . . c c c c . . . .
. . . . . . c c d d d d c . . .
. . . . . c c c c c c d c . . .
. . . . c c 4 4 4 4 d c c . . .
. . . c 4 d 4 4 4 4 4 1 c . c c
. . c 4 4 4 1 4 4 4 4 d 1 c 4 c
. c 4 4 4 4 1 4 4 4 4 4 1 c 4 c
f 4 4 4 4 4 1 4 4 4 4 4 1 4 4 f
f 4 4 4 f 4 1 c c 4 4 4 1 f 4 f
f 4 4 4 4 4 1 4 4 f 4 4 d f 4 f
. f 4 4 4 4 1 c 4 f 4 d f f f f
. . f f 4 d 4 4 f f 4 c f c . .
. . . . f f 4 4 4 4 c d b c . .
. . . . . . f f f f d d d c . .
. . . . . . . . . . c c c . . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . b b b b . . . .
. . . . . . b b d d d d b . . .
. . . . b b b b b b b d b . b b
. . b b 1 1 d 1 1 1 1 d d b 1 b
. b 1 1 1 1 d 1 1 1 1 1 d b 1 b
b 1 1 1 1 1 d 1 1 1 1 1 d 1 1 b
b 1 1 1 f 1 d b b 1 1 1 d b 1 c
b 1 1 1 1 1 d 1 1 b 1 1 d c 1 c
. b 1 1 1 1 d b 1 b 1 d c c c c
. . c c 1 d 1 1 b b 1 c c c . .
. . . . c c 1 1 1 1 c d c . . .
. . . . . . c c c c c c . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . b b b . . . . .
. . . . . . b b d d d b . . . .
. . . . b b b b b b b d b . b b
. . b b d 2 2 2 2 2 b d d b 5 b
. b 7 7 d 2 4 4 2 2 2 2 d 5 5 b
b 7 f 7 d 2 2 2 4 2 2 2 d b 5 c
b 7 7 7 d 2 4 2 4 2 2 2 d c 5 c
. b 7 d 2 2 2 4 4 2 2 d c c c c
. . c c 1 1 1 1 1 1 1 1 c . . .
. . . . c c c c c c c c . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`]]
right_fish_animations = [[img`
. . . . . . . . . . . . . . . .
. . . c c c c c . . . . . . . .
. . c 5 5 5 5 5 c c . . . . . .
. c 5 5 5 5 5 5 5 5 c . . . . .
. c 5 5 5 b b b b b b c . . . .
. . c c b b 1 b b 1 1 c . . . .
. . . c 1 1 1 b b 1 1 1 c . . .
c c . c 1 1 1 b 1 1 1 1 c . . .
c 5 b b 1 1 1 b 1 1 1 d c . . .
c 5 5 5 1 b 1 b 1 c 1 d c c . .
c 5 b b 1 b 1 1 1 1 1 d d c c .
c c . f 1 b b 1 1 1 1 1 d d d f
. . . f b b b 1 1 1 1 1 1 f f f
. . f 5 5 b b b 1 1 1 f f . . .
. . f 5 5 5 5 5 f f f . . . . .
. . f f f f f f . . . . . . . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . c c c c . . . . . . . .
. . . c d d d d c c . . . . . .
. . . c d c c c c c c . . . . .
. . . c c d 4 4 4 4 c c . . . .
c c . c 1 4 4 4 4 4 d 4 c . . .
c 4 c 1 d 4 4 4 4 1 4 4 4 c . .
c 4 c 1 4 4 4 4 4 1 4 4 4 4 c .
f 4 4 1 4 4 4 4 4 1 4 4 4 4 4 f
f 4 f 1 4 4 4 c c 1 4 f 4 4 4 f
f 4 f d 4 4 f 4 4 1 4 4 4 4 4 f
f f f f d 4 f 4 c 1 4 4 4 4 f .
. . c f c 4 f f 4 4 d 4 f f . .
. . c b d c 4 4 4 4 f f . . . .
. . c d d d f f f f . . . . . .
. . . c c c . . . . . . . . . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . b b b b . . . . . . . .
. . . b d d d d b b . . . . . .
b b . b d b b b b b b b . . . .
b 1 b d d 1 1 1 1 d 1 1 b b . .
b 1 b d 1 1 1 1 1 d 1 1 1 1 b .
b 1 1 d 1 1 1 1 1 d 1 1 1 1 1 b
c 1 b d 1 1 1 b b d 1 f 1 1 1 b
c 1 c d 1 1 b 1 1 d 1 1 1 1 1 b
c c c c d 1 b 1 b d 1 1 1 1 b .
. . c c c 1 b b 1 1 d 1 c c . .
. . . c d c 1 1 1 1 c c . . . .
. . . . c c c c c c . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`], [img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . b b b . . . . . . . .
. . . . b d d d b b . . . . . .
b b . b d b b b b b b b . . . .
b 5 b d d b 2 2 2 2 2 d b b . .
b 5 5 d 2 2 2 2 4 4 2 d 7 7 b .
c 5 b d 2 2 2 4 2 2 2 d 7 f 7 b
c 5 c d 2 2 2 4 2 4 2 d 7 7 7 b
c c c c d 2 2 4 4 2 2 2 d 7 b .
. . . c 1 1 1 1 1 1 1 1 c c . .
. . . . c c c c c c c c . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`]]
local_choice = randint(0, left_fish_animations.length - 1)
sprite_fish = sprites.create(right_fish_animations[local_choice][0], SpriteKind.NPC)
tiles.placeOnRandomTile(sprite_fish, myTiles.tile13)
tiles.setTileAt(tiles.locationOfSprite(sprite_fish), myTiles.tile15)
character.loopFrames(
sprite_fish,
left_fish_animations[local_choice],
100,
character.rule(Predicate.MovingLeft)
)
character.loopFrames(
sprite_fish,
right_fish_animations[local_choice],
100,
character.rule(Predicate.MovingRight)
)
if (force_animate) {
character.setCharacterState(sprite_fish, character.rule(Predicate.MovingRight))
}
timer.background(function () {
if (ai) {
location = tiles.getTilesByType(myTiles.tile16)[randint(0, tiles.getTilesByType(myTiles.tile16).length - 1)]
tiles.setTileAt(location, myTiles.tile12)
paths.push(scene.aStar(tiles.locationOfSprite(sprite_fish), location))
sprites.setDataNumber(sprite_fish, "path_index", paths.length - 1)
sprites.setDataNumber(sprite_fish, "target_row", tiles.locationXY(location, tiles.XY.row))
sprites.setDataNumber(sprite_fish, "target_col", tiles.locationXY(location, tiles.XY.column))
sprites.setDataBoolean(sprite_fish, "running_away", false)
}
})
multilights.addLightSource(sprite_fish, 4)
return sprite_fish
}
spriteutils.createRenderable(200, function (screen2) {
if (loading >= 0) {
screen2.fill(15)
screen2.drawRect(scene.screenWidth() / 2 - 50, scene.screenHeight() / 2 - 3, 100, 6, 1)
screen2.fillRect(scene.screenWidth() / 2 - 48, scene.screenHeight() / 2 - 1, Math.map(loading * 100, 0, 100, 0, 96), 2, 1)
images.printCenter(screen2, message, scene.screenHeight() * 0.55, 1)
}
})
scene.onOverlapTile(SpriteKind.NPC, myTiles.tile12, function (sprite, location) {
sprite.setKind(SpriteKind.SurvivedNPC)
if (!(last_15)) {
last_15 = true
info.stopCountdown()
timer.after(100, function () {
info.startCountdown(15)
})
}
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_game) {
show_minimap = !(show_minimap)
sprite_map.setFlag(SpriteFlag.Invisible, show_minimap)
}
})
function fade_out () {
color.startFade(color.Black, color.originalPalette, 2000)
color.pauseUntilFadeDone()
}
function wait_for_select_and_close () {
selected_option = false
while (!(selected_option)) {
pause(100)
}
blockMenu.closeMenu()
}
info.onCountdownEnd(function () {
if (!(in_game)) {
for (let index = 0; index <= 9; index++) {
tiles.setWallAt(tiles.getTileLocation(3, index + 1), false)
}
for (let sprite of sprites.allOfKind(SpriteKind.NPC)) {
scene.followPath(sprite, paths[sprites.readDataNumber(sprite, "path_index")], randint(40, 80))
}
in_game = true
timer.after(100, function () {
info.startCountdown(60)
})
} else {
in_game = false
game.over(player_made_it)
}
})
function fade_in () {
color.startFade(color.originalPalette, color.Black, 2000)
color.pauseUntilFadeDone()
}
scene.onOverlapTile(SpriteKind.Player, myTiles.tile12, function (sprite, location) {
player_made_it = true
sprite.setKind(SpriteKind.SurvivedPlayer)
if (!(last_15)) {
last_15 = true
info.stopCountdown()
timer.after(100, function () {
info.startCountdown(15)
})
info.changeScoreBy(10000)
}
})
sprites.onOverlap(SpriteKind.NPC, SpriteKind.Enemy, function (sprite, otherSprite) {
sprite.destroy(effects.spray, 100)
sprites.changeDataNumberBy(otherSprite, "speed_dif", -16)
timer.after(500, function () {
sprites.changeDataNumberBy(otherSprite, "speed_dif", 18)
})
character.setCharacterAnimationsEnabled(otherSprite, false)
if (otherSprite.image.equals(img`
.............ccfff..............
...........ccddbcf..............
..........ccddbbf...............
..........fccbbcf...............
.....fffffccccccff.........ccc..
...ffbbbbbbbcbbbbcfff....ccbbc..
..fbbbbbbbbcbcbbbbcccff.cdbbc...
ffbbbbbbffbbcbcbbbcccccfcdbbf...
fbcbbb11ff1bcbbbbbcccccffbbf....
fbbb11111111bbbbbcccccccbbcf....
.fb11133cc11bbbbcccccccccccf....
..fccc31c111bbbcccccbdbffbbcf...
...fc13c111cbbbfcddddcc..fbbf...
....fccc111fbdbbccdcc.....fbbf..
........ccccfcdbbcc........fff..
.............fffff..............
`)) {
otherSprite.setImage(img`
.fffffff...ccfff....................
fbbbbbbbffcbbbbf....................
fbb111bbbbbffbf.....................
fb11111ffbbbbff.....................
f1cccc1ffbbbbbcff...................
ffc1c1c1bbcbcbcccf..................
.fcc3331bbbcbcbcccf..ccccc..........
..c333c1bbbcbcbccccfcddbbc..........
..c333c1bbbbbbbcccccddbcc...........
..c333c11bbbbbccccccbbcc............
.cc331c11bbbbccccccfbccf............
.cc13c11cbbbcccccbbcfccf............
.c111111cbbbfdddddc.fbbcf...........
..cc1111fbdbbfdddc...fbbf...........
....cccfffbdbbfcc.....fbbf..........
..........fffff........fff..........
`)
} else {
otherSprite.setImage(img`
....................fffcc...fffffff.
....................fbbbbcffbbbbbbbf
.....................fbffbbbbb111bbf
.....................ffbbbbff11111bf
...................ffcbbbbbff1cccc1f
..................fcccbcbcbb1c1c1cff
..........ccccc..fcccbcbcbbb1333ccf.
..........cbbddcfccccbcbcbbb1c333c..
...........ccbddcccccbbbbbbb1c333c..
............ccbbccccccbbbbb11c333c..
............fccbfccccccbbbb11c133cc.
............fccfcbbcccccbbbc11c31cc.
...........fcbbf.cdddddfbbbc111111c.
...........fbbf...cdddfbbdbf1111cc..
..........fbbf.....ccfbbdbfffccc....
..........fff........fffff..........
`)
}
timer.after(100, function () {
character.setCharacterAnimationsEnabled(otherSprite, true)
})
})
function start_game () {
info.startCountdown(5)
timer.background(function () {
for (let index = 0; index < 4; index++) {
music.playTone(392, music.beat(BeatFraction.Quarter))
pause(1000)
}
music.playTone(587, music.beat(BeatFraction.Half))
})
}
function initilize_map () {
scene.setBackgroundColor(9)
tiles.setTilemap(tiles.createTilemap(hex`40000c000202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020213131314141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151616161414141515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151516161614141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151616161414141515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151516161614141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414150f151515151515151515151515151515151515151515151515151515151515150f15151515151515151515151515151515151515151515150f1616161414140c1015151515151515150c151515151515151515151515151515150c15151515151015151515151515151515151515150c1515151515151515101616161414140d1103151515151515150d0809151515151515030405151515150b0e151515150312091515150b1515150706151515150d150a1515151503151116161601010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`, img`
2222222222222222222222222222222222222222222222222222222222222222
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
.....2........2.......222.....2....2.........22......2....2.....
2222222222222222222222222222222222222222222222222222222222222222
`, [myTiles.transparency16,sprites.builtin.oceanSand6,sprites.dungeon.hazardWater,sprites.builtin.coral0,sprites.builtin.coral4,sprites.builtin.coral5,sprites.builtin.coral2,sprites.builtin.coral1,myTiles.tile1,myTiles.tile2,myTiles.tile3,myTiles.tile4,myTiles.tile5,myTiles.tile6,myTiles.tile7,myTiles.tile8,myTiles.tile9,myTiles.tile10,myTiles.tile11,myTiles.tile14,myTiles.tile13,myTiles.tile15,myTiles.tile16], TileScale.Sixteen))
for (let index = 0; index <= user_shark_count - 1; index++) {
summon_shark()
loading += 1 / user_shark_count
message = "(" + (index + 1) + "/" + user_shark_count + ")"
pause(20)
}
loading = 1
pause(100)
loading = 0
for (let index = 0; index <= user_fish_count - 2; index++) {
summon_fish(true, true)
loading += 1 / (user_fish_count - 1)
message = "(" + (index + 1) + "/" + (user_fish_count - 1) + ")"
pause(20)
}
loading = 1
pause(100)
tiles.setTilemap(tiles.createTilemap(hex`40000c000202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020213131314141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151616161414141515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151516161614141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151616161414141515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151516161614141415151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515161616141414150f151515151515151515151515151515151515151515151515151515151515150f15151515151515151515151515151515151515151515150f1616161414140c1015151515151515150c151515151515151515151515151515150c15151515151015151515151515151515151515150c1515151515151515101616161414140d1103151515151515150d0809151515151515030405151515150b0e151515150312091515150b1515150706151515150d150a1515151503151116161601010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`, img`
2222222222222222222222222222222222222222222222222222222222222222
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2............................................................
...2.2........2.......222.....2....2.........22......2....2.....
2222222222222222222222222222222222222222222222222222222222222222
`, [myTiles.transparency16,sprites.builtin.oceanSand6,sprites.dungeon.hazardWater,sprites.builtin.coral0,sprites.builtin.coral4,sprites.builtin.coral5,sprites.builtin.coral2,sprites.builtin.coral1,myTiles.tile1,myTiles.tile2,myTiles.tile3,myTiles.tile4,myTiles.tile5,myTiles.tile6,myTiles.tile7,myTiles.tile8,myTiles.tile9,myTiles.tile10,myTiles.tile11,myTiles.tile14,myTiles.tile13,myTiles.tile15,myTiles.tile12], TileScale.Sixteen))
sprite_player_fish = summon_fish(false, false)
sprite_player_fish.setKind(SpriteKind.Player)
controller.moveSprite(sprite_player_fish, 64, 64)
scene.cameraFollowSprite(sprite_player_fish)
for (let location of tiles.getTilesByType(myTiles.tile13)) {
tiles.setTileAt(location, myTiles.tile15)
}
info.setScore(60000)
}
function update_minimap () {
map = minimap.minimap(MinimapScale.Eighth, 2, 11)
for (let sprite of sprites.allOfKind(SpriteKind.NPC)) {
minimap.includeSprite(map, sprite, MinimapSpriteScale.MinimapScale)
}
for (let sprite of sprites.allOfKind(SpriteKind.SurvivedNPC)) {
minimap.includeSprite(map, sprite, MinimapSpriteScale.MinimapScale)
}
for (let sprite of sprites.allOfKind(SpriteKind.Enemy)) {
minimap.includeSprite(map, sprite, MinimapSpriteScale.MinimapScale)
}
minimap.includeSprite(map, sprite_player_fish, MinimapSpriteScale.MinimapScale)
return minimap.getImage(map)
}
function summon_shark () {
sprite_shark = sprites.create(img`
.............ccfff..............
...........ccddbcf..............
..........ccddbbf...............
..........fccbbcf...............
.....fffffccccccff.........ccc..
...ffbbbbbbbcbbbbcfff....ccbbc..
..fbbbbbbbbcbcbbbbcccff.cdbbc...
ffbbbbbbffbbcbcbbbcccccfcdbbf...
fbcbbb11ff1bcbbbbbcccccffbbf....
fbbb11111111bbbbbcccccccbbcf....
.fb11133cc11bbbbcccccccccccf....
..fccc31c111bbbcccccbdbffbbcf...
...fc13c111cbbbfcddddcc..fbbf...
....fccc111fbdbbccdcc.....fbbf..
........ccccfcdbbcc........fff..
.............fffff..............
`, SpriteKind.Enemy)
sprites.setDataNumber(sprite_shark, "speed_dif", 0)
tiles.placeOnRandomTile(sprite_shark, myTiles.tile15)
while (tiles.locationXY(tiles.locationOfSprite(sprite_shark), tiles.XY.column) <= 20) {
tiles.placeOnRandomTile(sprite_shark, myTiles.tile15)
}
character.loopFrames(
sprite_shark,
[img`
.............ccfff..............
...........ccddbcf..............
..........ccddbbf...............
..........fccbbcf...............
.....fffffccccccff.........ccc..
...ffbbbbbbbcbbbbcfff....ccbbc..
..fbbbbbbbbcbcbbbbcccff.cdbbc...
ffbbbbbbffbbcbcbbbcccccfcdbbf...
fbcbbb11ff1bcbbbbbcccccffbbf....
fbbb11111111bbbbbcccccccbbcf....
.fb11133cc11bbbbcccccccccccf....
..fccc31c111bbbcccccbdbffbbcf...
...fc13c111cbbbfcddddcc..fbbf...
....fccc111fbdbbccdcc.....fbbf..
........ccccfcdbbcc........fff..
.............fffff..............
`],
250,
character.rule(Predicate.MovingLeft)
)
character.loopFrames(
sprite_shark,
[img`
..............fffcc.............
..............fcbddcc...........
...............fbbddcc..........
...............fcbbccf..........
..ccc.........ffccccccfffff.....
..cbbcc....fffcbbbbcbbbbbbbff...
...cbbdc.ffcccbbbbcbcbbbbbbbbf..
...fbbdcfcccccbbbcbcbbffbbbbbbff
....fbbffcccccbbbbbcb1ff11bbbcbf
....fcbbcccccccbbbbb11111111bbbf
....fcccccccccccbbbb11cc33111bf.
...fcbbffbdbcccccbbb111c13cccf..
...fbbf..ccddddcfbbbc111c31cf...
..fbbf.....ccdccbbdbf111cccf....
..fff........ccbbdcfcccc........
..............fffff.............
`],
250,
character.rule(Predicate.MovingRight)
)
multilights.addLightSource(sprite_shark, 10)
return sprite_shark
}
function create_minimap () {
sprite_map = sprites.create(update_minimap(), SpriteKind.Map)
sprite_map.bottom = scene.screenHeight() - 2
sprite_map.x = scene.screenWidth() / 2
sprite_map.z = 500
sprite_map.setFlag(SpriteFlag.RelativeToCamera, true)
}
blockMenu.onMenuOptionSelected(function (option, index) {
selected_option = true
if (in_menu) {
music.playTone(294, music.beat(BeatFraction.Quarter))
}
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
if (true) {
sprite.destroy(effects.spray, 100)
}
sprites.changeDataNumberBy(otherSprite, "speed_dif", -16)
timer.after(500, function () {
sprites.changeDataNumberBy(otherSprite, "speed_dif", 18)
})
character.setCharacterAnimationsEnabled(otherSprite, false)
if (otherSprite.image.equals(img`
.............ccfff..............
...........ccddbcf..............
..........ccddbbf...............
..........fccbbcf...............
.....fffffccccccff.........ccc..
...ffbbbbbbbcbbbbcfff....ccbbc..
..fbbbbbbbbcbcbbbbcccff.cdbbc...
ffbbbbbbffbbcbcbbbcccccfcdbbf...
fbcbbb11ff1bcbbbbbcccccffbbf....
fbbb11111111bbbbbcccccccbbcf....
.fb11133cc11bbbbcccccccccccf....
..fccc31c111bbbcccccbdbffbbcf...
...fc13c111cbbbfcddddcc..fbbf...
....fccc111fbdbbccdcc.....fbbf..
........ccccfcdbbcc........fff..
.............fffff..............
`)) {
otherSprite.setImage(img`
.fffffff...ccfff....................
fbbbbbbbffcbbbbf....................
fbb111bbbbbffbf.....................
fb11111ffbbbbff.....................
f1cccc1ffbbbbbcff...................
ffc1c1c1bbcbcbcccf..................
.fcc3331bbbcbcbcccf..ccccc..........
..c333c1bbbcbcbccccfcddbbc..........
..c333c1bbbbbbbcccccddbcc...........
..c333c11bbbbbccccccbbcc............
.cc331c11bbbbccccccfbccf............
.cc13c11cbbbcccccbbcfccf............
.c111111cbbbfdddddc.fbbcf...........
..cc1111fbdbbfdddc...fbbf...........
....cccfffbdbbfcc.....fbbf..........
..........fffff........fff..........
`)
} else {
otherSprite.setImage(img`
....................fffcc...ffff
....................fbbbbcffbbbb
.....................fbffbbbbb11
.....................ffbbbbff111
...................ffcbbbbbff1cc
..................fcccbcbcbb1c1c
..........ccccc..fcccbcbcbbb1333
..........cbbddcfccccbcbcbbb1c33
...........ccbddcccccbbbbbbb1c33
............ccbbccccccbbbbb11c33
............fccbfccccccbbbb11c13
............fccfcbbcccccbbbc11c3
...........fcbbf.cdddddfbbbc1111
...........fbbf...cdddfbbdbf1111
..........fbbf.....ccfbbdbfffccc
..........fff........fffff......
`)
}
timer.after(100, function () {
character.setCharacterAnimationsEnabled(otherSprite, true)
})
scene.cameraFollowSprite(otherSprite)
timer.after(4500, function () {
in_game = false
pause(500)
game.over(false)
})
})
let sprite_closest_sprite: Sprite = null
let shortest_distance = 0
let last_score_time = 0
let sprite_shark: Sprite = null
let map: minimap.Minimap = null
let selected_option = false
let sprite_map: Sprite = null
let location: tiles.Location = null
let sprite_fish: Sprite = null
let local_choice = 0
let right_fish_animations: Image[][] = []
let left_fish_animations: Image[][] = []
let shortest_shark_distance = 0
let sprite_player_fish: Sprite = null
let message = ""
let loading = 0
let show_minimap = false
let paths: tiles.Location[][] = []
let in_menu = false
let last_15 = false
let player_made_it = false
let in_game = false
let dark_mode = false
let user_shark_count = 0
let user_fish_count = 0
if (blockSettings.exists("fish_count")) {
// max is 31
user_fish_count = blockSettings.readNumber("fish_count")
} else {
// max is 31
user_fish_count = 31
}
if (blockSettings.exists("shark_count")) {
// max is 31
user_shark_count = blockSettings.readNumber("shark_count")
} else {
// max is 31
user_shark_count = 2
}
if (blockSettings.exists("dark_mode")) {
// max is 31
dark_mode = blockSettings.readNumber("dark_mode") == 1
} else {
// max is 31
dark_mode = false
}
in_game = false
player_made_it = false
last_15 = false
in_menu = true
paths = []
show_minimap = true
let play_music = true
loading = -1
message = ""
scene.setBackgroundColor(9)
scene.setBackgroundImage(img`
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
......666666666...666666666...666666666...666...666...666...666......666666666...666666666...666666666...666...666...666...666..................................
......6888888888..6888888888..6888888888..6888..6888..6888..6888.....6888888888..6888888888..6888888888..6888..6888..6888..6888.................................
......6888888888..6888888888..6888888888..6888..6888..6888..6888.....6888888888..6888888888..6888888888..6888..6888..6888..6888.................................
......6888888888...888888888..6888888888..6888..6888..6888..6888.....6888888888...888888888..6888888888..6888..6888..6888..6888.................................
......6888...........6888.....6888........6888..6888..6888..6888.....6888...........6888.....6888........6888..6888..6888..6888.................................
......6888...........6888.....6888........6888..6888..6888..6888.....6888...........6888.....6888........6888..6888..6888..6888.................................
......688866666......6888.....688866666...6888666888..6888666888.....688866666......6888.....688866666...6888666888..6888666888...................ccccc.........
......6888888888.....6888.....6888888888..6888888888..6888888888.....6888888888.....6888.....6888888888..6888888888..6888888888................ccc5555cc........
......6888888888.....6888.....6888888888..6888888888..6888888888.....6888888888.....6888.....6888888888..6888888888..6888888888..............cc55555555c........
......6888888888.....6888......888888888..6888888888...888888888.....6888888888.....6888......888888888..6888888888...888888888..............cbbbbbb555c........
......6888...........6888............888..6888..6888.....6888........6888...........6888............888..6888..6888.....6888................c111bb1bbcc.........
......6888...........6888............888..6888..6888.....6888........6888...........6888............888..6888..6888.....6888................c1111b111c.cc.......
......6888........666688866...6666666888..6888..6888.....6888........6888........666688866...6666666888..6888..6888.....6888................cd111b111cb5c.......
......6888........6888888888..6888888888..6888..6888.....6888........6888........6888888888..6888888888..6888..6888.....6888...............ccd1c1b111bb5c.......
......6888........6888888888..6888888888..6888..6888.....6888........6888........6888888888..6888888888..6888..6888.....6888.............cccdd111b1b1555c.......
.......888.........888888888...888888888...888...888......888.........888.........888888888...888888888...888...888......888.............fddd111111b1bbcc.......
..........................................................................................................................................ff111111bb1f..........
............................................................................................................................................f11111bbbf..........
......666666666...666666666...666666666...666666666...666666666......666.........666...666...666.............................................ff11bb55f..........
......6888888888..6888888888..6888888888..6888888888..6888888888.....6888........6888..6888..6888..............................................f55555f..........
......6888888888..6888888888..6888888888..6888888888..6888888888.....6888........6888..6888..6888...............................................ffffff..........
......6888888888..6888888888..6888888888..6888888888..6888888888.....688866...6666888..6888..6888...............................................................
......6888........6888...888..6888..6888..6888........6888...........6888888..6888888..6888..6888...............................................................
......6888........6888...888..6888..6888..6888........6888...........6888888..6888888..6888..6888...................................cccc........................
......6888........688866.888..6888..6888..688866666...688866666......6888888666888888..6888666888..................................cddddcc......................
......6888........6888888.....6888..6888..6888888888..6888888888.....6888..6888..6888..6888888888..................................cddcccccc....................
......6888........6888888.....6888..6888..6888888888..6888888888.....6888..6888..6888..6888888888.............fffcc...fffffff....cccccd4444ccc..................
......6888........688888866...6888..6888...888888888...888888888.....6888..6888..6888...888888888.............fbbbbcffbbbbbbbf...f4cc144444144c.................
......6888........6888..6888..6888..6888.........888.........888.....6888........6888.....6888.................fbffbbbbb111bbf...f4f1d444414444c................
......6888........6888..6888..6888..6888.........888.........888.....6888........6888.....6888.................ffbbbbff11111bf...f4f144444144444f...............
......688866666...6888..6888..6888666888..6666666888..6666666888.....6888........6888.....6888...............ffcbbbbbff1cccc1f...f44144fc4144f44f...............
......6888888888..6888..6888..6888888888..6888888888..6888888888.....6888........6888.....6888..............fcccbcbcbb1c1c1cff...fff144f4c144444f...............
......6888888888..6888..6888..6888888888..6888888888..6888888888.....6888........6888.....6888......ccccc..fcccbcbcbbb1333ccf......fd44f4414444f................
.......888888888...888..6888...888888888...888888888...888888888......888.........888......888......cbbddcfccccbcbcbbb1c333c........fd44cc4144f.................
.....................................................................................................ccbddcccccbbbbbbb1c333c........fc444444df..................
......................................................................................................ccbbccccccbbbbb11c333c.......cbdc4444ff...................
......666666666...666666666...666666666...666666666...6666.....666...666..............................fccbfccccccbbbb11c133cc......cdddffff.....................
......6888888888..6888888888..6888888888..6888888888..6888.....6888..6888..8...888...8................fccfcbbcccccbbbc11c31cc.......ccc.........................
......6888888888..6888888888..6888888888..6888888888..6888.....6888..6888..8.....8...8...............fcbbf.cdddddfbbbc111111c...................................
......6888888888..6888888888..6888888888..6888888888..688866...6888..6888..8...888...8...............fbbf...cdddfbbdbf1111cc....................................
......6888..6888..6888........6888........6888..6888..6888888..6888..6888..8.....8...8..............fbbf.....ccfbbdbfffccc......................................
......6888..6888..6888........6888........6888..6888..6888888..6888..6888..8.8.888.8.8..............fff........fffff............................................
......6888..6888..6888........688866666...6888666888..6888888666888..6888.......................................................................................
......6888..6888..6888........6888888888..6888888888..6888..6888888..6888.......................................................................................
......6888..6888..6888........6888888888..6888888888..6888..6888888..6888.......................................................................................
......6888..6888..6888........6888888888..6888888888..6888..6888888...888.......................................................................................
......6888..6888..6888........6888........6888..6888..6888.....6888.............................................................................................
......6888..6888..6888........6888........6888..6888..6888.....6888........88..8.8...8.8.8..8.888.888.8888.8..8.888.88......888.888.88..8.8.888.8..8.888........
......6888666888..688866666...688866666...6888..6888..6888.....6888..666...8.8.8.8...8.8.88.8.8....8..8....88.8.8...8.8.....8.8.8.8.8.8.8.8..8..88.8.8.8........
......6888888888..6888888888..6888888888..6888..6888..6888.....6888..6888..88..888...8.8.8.88.888..8..8.88.8.88.888.8.8.....888.88..8.8.8.8..8..8.88.8.8........
......6888888888..6888888888..6888888888..6888..6888..6888.....6888..6888..8.8..8....8.8.8..8...8..8..8..8.8..8.8...8.8.....8.8.8.8.8.8.8.8..8..8..8.8.8........
.......888888888...888888888...888888888...888...888...888......888...888..88...8....888.8..8.888.888.8888.8..8.888.88..888.8.8.8.8.88..888.888.8..8.888........
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
`)
tiles.setTilemap(tiles.createTilemap(hex`0a00080000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000090000000000000000020a0500070004030601010101010101010101`, img`
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
`, [myTiles.transparency16,sprites.builtin.oceanSand6,sprites.builtin.coral0,sprites.builtin.coral2,sprites.builtin.coral1,myTiles.tile2,myTiles.tile3,myTiles.tile4,myTiles.tile8,myTiles.tile9,myTiles.tile11], TileScale.Sixteen))
fade_out()
while (in_menu) {
blockMenu.setColors(9, 8)
blockMenu.showMenu(["Play", "Instructions", "Set fish count", "Set shark count", "Default options"], MenuStyle.List, MenuLocation.BottomHalf)
wait_for_select_and_close()
if (blockMenu.selectedMenuIndex() == 0) {
game.showLongText("Selected options:\\n" + user_fish_count + " fish\\n" + user_shark_count + " shark(s)\\n", DialogLayout.Bottom)
if (game.ask("Continue with these", "options?")) {
in_menu = false
}
} else if (blockMenu.selectedMenuIndex() == 1) {
game.showLongText("Hello there! Welcome to Fishy Fishy Cross My Ocean!", DialogLayout.Bottom)
game.showLongText("In this game, all you have to do is guide your fish " + "(Using the arrow keys or W, A, S, and D - If you figured " + "out how to run this on hardware whilst also being playable " + "please tell me) to the other end! Simple, right?" + "", DialogLayout.Bottom)
game.showLongText("Unfortunately for you, no.\\n" + "There will be some sharks patrolling the waters. And they " + "are hungry! (As you can see in figure A. - the picture above)" + "" + "", DialogLayout.Bottom)
game.showLongText("Just try to swim around them. You might have to sacrifice a couple " + "AI fish to get around them, because in this game, the sharks are " + "pretty dumb. They go for the nearest fish. That's what their " + "two brain cells do in this game. (And eat them) Just don't do " + "this in real life, and you'll be fine.", DialogLayout.Bottom)
game.showLongText("Good luck, and hope you don't become a shark's breakfast!", DialogLayout.Bottom)
game.showLongText("Note: Please do not play this game if you have galeophobia and/or thalassophobia.", DialogLayout.Bottom)
} else if (blockMenu.selectedMenuIndex() == 2) {
user_fish_count = game.askForNumber("Please input the amount of fish you want:", 2)
if (user_fish_count > 31) {
game.showLongText("31 is the maximum amount of fish! (Fish count is now 31)", DialogLayout.Bottom)
user_fish_count = 31
} else if (user_fish_count < 1) {
game.showLongText("1 is the minimum amount of fish! (Fish count is now 1)", DialogLayout.Bottom)
user_fish_count = 1
} else if (user_fish_count != user_fish_count) {
game.showLongText("That's not a number! (Fish count is now 31)", DialogLayout.Bottom)
user_fish_count = 31
} else {
game.showLongText("Fish count is now " + user_fish_count + "!", DialogLayout.Bottom)
}
} else if (blockMenu.selectedMenuIndex() == 3) {
user_shark_count = game.askForNumber("Please input the amount of sharks you want:", 1)
if (user_shark_count < 1) {
game.showLongText("1 is the minimum amount of sharks! (Shark count is now 1)", DialogLayout.Bottom)
user_shark_count = 1
} else if (user_shark_count != user_shark_count) {
game.showLongText("That's not a number! (Shark count is now 2)", DialogLayout.Bottom)
user_shark_count = 2
} else {
game.showLongText("Shark count is now " + user_shark_count + "!", DialogLayout.Bottom)
}
} else if (blockMenu.selectedMenuIndex() == 4) {
game.showLongText("Default options set!", DialogLayout.Bottom)
user_fish_count = 31
user_shark_count = 2
}
}
fade_in()
scene.setBackgroundImage(img`
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
................................................................................................................................................................
`)
loading = 0
blockSettings.writeNumber("fish_count", user_fish_count)
blockSettings.writeNumber("shark_count", user_shark_count)
fade_out()
let loading_start_time = game.runtime()
initilize_map()
message = "Took " + (game.runtime() - loading_start_time) / 1000 + " seconds"
fade_in()
loading = -1
multilights.toggleLighting(dark_mode)
create_minimap()
start_game()
fade_out()
timer.after(5000, function () {
while (play_music) {
if (spriteutils.isDestroyed(sprite_player_fish)) {
music.playTone(117, music.beat(BeatFraction.Half))
music.playTone(110, music.beat(BeatFraction.Double))
play_music = false
} else {
music.playTone(110, music.beat(BeatFraction.Whole))
music.playTone(117, music.beat(BeatFraction.Quarter))
shortest_shark_distance = 10000000000000000
for (let sprite of sprites.allOfKind(SpriteKind.Enemy)) {
if (spriteutils.distanceBetween(sprite_player_fish, sprite) < shortest_shark_distance) {
shortest_shark_distance = spriteutils.distanceBetween(sprite_player_fish, sprite)
}
}
pause(shortest_shark_distance * 10)
}
}
})
forever(function () {
sprite_map.setImage(update_minimap())
})
forever(function () {
if (sprites.allOfKind(SpriteKind.NPC).length == 0 && player_made_it) {
info.stopCountdown()
pause(1000)
info.startCountdown(0)
}
pause(100)
})
forever(function () {
if (in_game) {
last_score_time = game.runtime()
pause(100)
info.changeScoreBy(last_score_time - game.runtime())
} else {
pause(100)
}
})
forever(function () {
if (in_game) {
for (let sprite_fish of sprites.allOfKind(SpriteKind.NPC)) {
for (let sprite_shark of sprites.allOfKind(SpriteKind.Enemy)) {
if (spriteutils.distanceBetween(sprite_fish, sprite_shark) < 48 && !(sprites.readDataBoolean(sprite_fish, "running_away"))) {
scene.followPath(sprite_fish, paths[sprites.readDataNumber(sprite_fish, "path_index")], 0)
spriteutils.setVelocityAtAngle(sprite_fish, spriteutils.angleFrom(sprite_shark, sprite_fish), 70)
sprites.setDataBoolean(sprite_fish, "running_away", true)
if (true) {
timer.after(500, function () {
scene.followPath(sprite_fish, scene.aStar(tiles.locationOfSprite(sprite_fish), tiles.getTileLocation(sprites.readDataNumber(sprite_fish, "target_col"), sprites.readDataNumber(sprite_fish, "target_row"))), randint(40, 80))
sprites.setDataBoolean(sprite_fish, "running_away", false)
})
}
}
}
pause(50)
}