forked from CelesteClassic/newleste.p8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temple.p8
2173 lines (2006 loc) · 78.1 KB
/
temple.p8
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
pico-8 cartridge // http://www.pico-8.com
version 32
__lua__
--newleste.p8 base cart
--original game by:
--maddy thorson + noel berry
-- based on evercore v2.0.2
--with major project contributions by
--taco360, meep, gonengazit, and akliant
-- [data structures]
function vector(x,y)
return {x=x,y=y}
end
function rectangle(x,y,w,h)
return {x=x,y=y,w=w,h=h}
end
-- [globals]
--tables
objects,got_fruit={},{}
--timers
freeze,delay_restart,sfx_timer,music_timer,ui_timer=0,0,0,0,-99
--camera values
--<camtrigger>--
cam_x,cam_y,cam_spdx,cam_spdy,cam_gain,cam_offx,cam_offy=0,0,0,0,0.25,0,0
--</camtrigger>--
_pal=pal --for outlining
local _g=_ENV --for writing to global vars
-- [entry point]
function _init()
max_djump,deaths,frames,seconds,minutes,music_timer,time_ticking,berry_count=1,0,0,0,0,0,true,0
music(0,0,7)
load_level(1)
end
-- [effects]
function rnd128()
return rnd(128)
end
clouds={}
for i=0,16 do
add(clouds,{
x=rnd128(),
y=rnd128(),
spd=1+rnd(4),
w=32+rnd(32)
})
end
particles={}
for i=0,24 do
add(particles,{
x=rnd128(),
y=rnd128(),
s=flr(rnd(1.25)),
spd=0.25+rnd(5),
off=rnd(),
c=6+rnd(2),
})
end
dead_particles={}
-- [player entity]
player={
layer=2,
init=function(_ENV)
grace,jbuffer=0,0
djump=max_djump
dash_time,dash_effect_time=0,0
dash_target_x,dash_target_y=0,0
dash_accel_x,dash_accel_y=0,0
hitbox=rectangle(1,3,6,5)
spr_off=0
collides=true
create_hair(_ENV)
-- <fruitrain> --
berry_timer=0
berry_count=0
-- <keydoor> --
key_count=0
-- </keydoor> --
-- </fruitrain> --
end,
update=function(_ENV)
if pause_player then
return
end
-- horizontal input
local h_input=btn(➡️) and 1 or btn(⬅️) and -1 or 0
-- spike collision / bottom death
if is_flag(0,0,-1) or
y>lvl_ph then
kill_player(_ENV)
end
-- on ground checks
local on_ground=is_solid(0,1)
-- <fruitrain> --
if on_ground then
berry_timer+=1
else
berry_timer=0
berry_count=0
end
for f in all(fruitrain) do
if f.type==fruit and not f.golden and berry_timer>5 and f then
-- to be implemented:
-- save berry
-- save golden
berry_timer=-5
berry_count+=1
_g.berry_count+=1
got_fruit[f.fruit_id]=true
init_object(lifeup, f.x, f.y,berry_count)
del(fruitrain, f)
destroy_object(f)
if (fruitrain[1]) fruitrain[1].target=_ENV
end
end
-- </fruitrain> --
-- landing smoke
if on_ground and not was_on_ground then
init_smoke(0,4)
end
-- jump and dash input
local jump,dash=btn(🅾️) and not p_jump,btn(❎) and not p_dash
p_jump,p_dash=btn(🅾️),btn(❎)
-- jump buffer
if jump then
jbuffer=4
elseif jbuffer>0 then
jbuffer-=1
end
-- grace frames and dash restoration
if on_ground then
grace=6
if djump<max_djump then
psfx(22)
djump=max_djump
end
elseif grace>0 then
grace-=1
end
-- dash effect timer (for dash-triggered events, e.g., berry blocks)
dash_effect_time-=1
-- dash startup period, accel toward dash target speed
if dash_time>0 then
init_smoke()
dash_time-=1
spd=vector(
appr(spd.x,dash_target_x,dash_accel_x),
appr(spd.y,dash_target_y,dash_accel_y)
)
else
-- x movement
local maxrun=1
local accel=on_ground and 0.6 or 0.4
local deccel=0.15
-- set x speed
spd.x=abs(spd.x)<=1 and
appr(spd.x,h_input*maxrun,accel) or
appr(spd.x,sign(spd.x)*maxrun,deccel)
-- facing direction
if spd.x~=0 then
flip.x=spd.x<0
end
-- y movement
local maxfall=2
-- wall slide
if h_input~=0 and is_solid(h_input,0) then
maxfall=0.4
-- wall slide smoke
if rnd(10)<2 then
init_smoke(h_input*6)
end
end
-- apply gravity
if not on_ground then
spd.y=appr(spd.y,maxfall,abs(spd.y)>0.15 and 0.21 or 0.105)
end
-- jump
if jbuffer>0 then
if grace>0 then
-- normal jump
psfx(18)
jbuffer=0
grace=0
spd.y=-2
init_smoke(0,4)
else
-- wall jump
local wall_dir=(is_solid(-3,0) and -1 or is_solid(3,0) and 1 or 0)
if wall_dir~=0 then
psfx(19)
jbuffer=0
spd=vector(wall_dir*(-1-maxrun),-2)
-- wall jump smoke
init_smoke(wall_dir*6)
end
end
end
-- dash
local d_full=5
local d_half=3.5355339059 -- 5 * sqrt(2)
--<theo_crystal> --
if holding then
if dash then
-- throw
if holding.is_solid(0,0) then -- can't throw
psfx(21)
init_smoke()
else
holding.spd=vector(flip.x and -4 or 4, -2)
holding.pspdx,holding.pspdy=holding.spd.x,-2
holding.cplayer=nil
holding=nil
end
end
-- <red_bubble> --
elseif djump>0 and dash or do_dash then
--</theo_crytal> --
do_dash=false
-- </red_bubble> --
init_smoke()
djump-=1
dash_time=4
_g.has_dashed=true
dash_effect_time=10
-- vertical input
local v_input=btn(⬆️) and -1 or btn(⬇️) and 1 or 0
-- calculate dash speeds
spd=vector(h_input~=0 and
h_input*(v_input~=0 and d_half or d_full) or
(v_input~=0 and 0 or flip.x and -1 or 1)
,v_input~=0 and v_input*(h_input~=0 and d_half or d_full) or 0)
-- effects
psfx(20)
_g.freeze=2
-- dash target speeds and accels
dash_target_x=2*sign(spd.x)
dash_target_y=(spd.y>=0 and 2 or 1.5)*sign(spd.y)
dash_accel_x=spd.y==0 and 1.5 or 1.06066017177 -- 1.5 * sqrt()
dash_accel_y=spd.x==0 and 1.5 or 1.06066017177
elseif djump<=0 and dash then
-- failed dash smoke
psfx(21)
init_smoke()
end
end
-- animation
spr_off+=0.25
sprite = not on_ground and (is_solid(h_input,0) and 5 or 3) or -- wall slide or mid air
btn(⬇️) and 6 or -- crouch
btn(⬆️) and 7 or -- look up
spd.x~=0 and h_input~=0 and 1+spr_off%4 or 1 -- walk or stand
update_hair(_ENV)
-- exit level off the top (except summit)
if y<-4 and levels[lvl_id+1] then
next_level()
end
-- was on the ground
was_on_ground=on_ground
--<theo_crystal> --
if holding then
holding.x=x-3
holding.y=y-12
end
--</theo_crystal> --
end,
draw=function(_ENV)
-- clamp in screen
local clamped=mid(x,-1,lvl_pw-7)
if x~=clamped then
x=clamped
spd.x=0
end
-- draw player hair and sprite
set_hair_color(djump)
draw_hair(_ENV)
draw_obj_sprite(_ENV)
pal()
end
}
function create_hair(_ENV)
hair={}
for i=1,5 do
add(hair,vector(x,y))
end
end
function set_hair_color(djump)
pal(8,djump==1 and 8 or 12)
end
function update_hair(_ENV)
local last=vector(x+4-(flip.x and-2 or 3),y+(btn(⬇️) and 4 or 2.9))
for h in all(hair) do
h.x+=(last.x-h.x)/1.5
h.y+=(last.y+0.5-h.y)/1.5
last=h
end
end
function draw_hair(_ENV)
for i,h in pairs(hair) do
circfill(round(h.x),round(h.y),mid(4-i,1,2),8)
end
end
-- [other entities]
player_spawn={
layer=2,
init=function(_ENV)
sfx(15)
sprite=3
target=y
y=min(y+48,lvl_ph)
_g.cam_x,_g.cam_y=mid(x,64,lvl_pw-64),mid(y,64,lvl_ph-64)
spd.y=-4
state=0
delay=0
create_hair(_ENV)
djump=max_djump
--- <keydoor> ---
key_count=0
--- <fruitrain> ---
for i=1,#fruitrain do
local f=init_object(fruitrain[i].type,x,y,fruitrain[i].sprite)
if fruitrain[i].type==key then
key_count+=1
end
f.follow=true
f.target=i==1 and _ENV or fruitrain[i-1]
f.r=fruitrain[i].r
f.fruit_id=fruitrain[i].fruit_id
fruitrain[i]=f
end
--- </fruitrain> </keydoor> ---
end,
update=function(_ENV)
-- jumping up
if state==0 and y<target+16 then
state=1
delay=3
-- falling
elseif state==1 then
spd.y+=0.5
if spd.y>0 then
if delay>0 then
-- stall at peak
spd.y=0
delay-=1
elseif y>target then
-- clamp at target y
y=target
spd=vector(0,0)
state=2
delay=5
init_smoke(0,4)
sfx(16)
end
end
-- landing and spawning player object
elseif state==2 then
delay-=1
sprite=6
if delay<0 then
destroy_object(_ENV)
local p=init_object(player,x,y)
-- <keydoor> --
p.key_count=key_count
-- </keydoor> --
--- <fruitrain> ---
if (fruitrain[1]) fruitrain[1].target=p
--- </fruitrain> ---
end
end
update_hair(_ENV)
end,
draw=player.draw
-- draw=function(this)
-- set_hair_color(max_djump)
-- draw_hair(this,1)
-- draw_obj_sprite(this)
-- unset_hair_color()
-- end
}
--<camtrigger>--
camera_trigger={
update=function(_ENV)
if timer and timer>0 then
timer-=1
if timer==0 then
_g.cam_offx=offx
_g.cam_offy=offy
else
_g.cam_offx+=cam_gain*(offx-cam_offx)
_g.cam_offy+=cam_gain*(offy-cam_offy)
end
elseif player_here() then
timer=5
end
end
}
--</camtrigger>--
spring={
init=function(_ENV)
dy,delay=0,0
end,
update=function(_ENV)
local hit=player_here()
if delay>0 then
delay-=1
elseif hit then
hit.y,hit.spd.y,hit.dash_time,hit.dash_effect_time,dy,delay,hit.djump=y-4,-3,0,0,4,10,max_djump
hit.spd.x*=0.2
psfx(14)
end
dy*=0.75
end,
draw=function(_ENV)
sspr(72,0,8,8-flr(dy),x,y+dy)
end
}
side_spring={
init=function(_ENV)
dx,dir=0,is_solid(-1,0) and 1 or -1
end,
update=function(_ENV)
local hit=player_here()
if hit then
hit.x,hit.spd.x,hit.spd.y,hit.dash_time,hit.dash_effect_time,dx,hit.djump=x+dir*4,dir*3,-1.5,0,0,4,max_djump
psfx(14)
end
dx*=0.75
end,
draw=function(_ENV)
local dx=flr(dx)
sspr(64,0,8-dx,8,x+dx*(dir-1)/-2,y,8-dx,8,dir==1)
end
}
refill={
init=function(_ENV)
offset=rnd()
timer=0
hitbox=rectangle(-1,-1,10,10)
active=true
end,
update=function(_ENV)
if active then
offset+=0.02
local hit=player_here()
if hit and hit.djump<max_djump then
psfx(11)
init_smoke()
hit.djump=max_djump
active=false
timer=60
end
elseif timer>0 then
timer-=1
else
psfx(12)
init_smoke()
active=true
end
end,
draw=function(_ENV)
if active then
spr(15,x,y+sin(offset)+0.5)
else
-- color(7)
-- line(x,y+4,x+3,y+7)
-- line(x+4,y+7,x+7,y+4)
-- line(x+7,y+3,x+4,y)
-- line(x+3,y,x,y+3)
foreach(split(
[[0,4,3,7
4,7,7,4
7,3,4,0
3,0,0,3]],"\n"),function(t)
local o1,o2,o3,o4=unpack(split(t))
line(x+o1,y+o2,x+o3,y+o4,7)
end
)
end
end
}
fall_floor={
init=function(_ENV)
solid_obj=true
state=0
end,
update=function(_ENV)
-- idling
if state==0 then
for i=0,2 do
if check(player,i-1,-(i%2)) then
psfx(13)
state,delay=1,15
init_smoke()
break
end
end
-- shaking
elseif state==1 then
delay-=1
if delay<=0 then
state=2
delay=60--how long it hides for
collideable=false
end
-- invisible, waiting to reset
elseif state==2 then
delay-=1
if delay<=0 and not player_here() then
psfx(12)
state=0
collideable=true
init_smoke()
end
end
end,
draw=function(_ENV)
spr(state==1 and 26-delay/5 or state==0 and 23,x,y) --add an if statement if you use sprite 0
end
}
smoke={
layer=3,
init=function(_ENV)
spd=vector(0.3+rnd(0.2),-0.1)
x+=-1+rnd(2)
y+=-1+rnd(2)
flip=vector(maybe(),maybe())
end,
update=function(_ENV)
sprite+=0.2
if sprite>=29 then
destroy_object(_ENV)
end
end
}
--- <fruitrain> ---
fruitrain={}
fruit={
check_fruit=true,
init=function(_ENV)
y_=y
off=0
follow=false
tx=x
ty=y
golden=sprite==11
if golden and deaths>0 then
destroy_object(_ENV)
end
end,
update=function(_ENV)
if not follow then
local hit=player_here()
if hit then
hit.berry_timer=0
follow=true
target=#fruitrain==0 and hit or fruitrain[#fruitrain]
r=#fruitrain==0 and 12 or 8
add(fruitrain,_ENV)
end
else
if target then
tx+=0.2*(target.x-tx)
ty+=0.2*(target.y-ty)
local a=atan2(x-tx,y_-ty)
local k=(x-tx)^2+(y_-ty)^2 > r^2 and 0.2 or 0.1
x+=k*(tx+r*cos(a)-x)
y_+=k*(ty+r*sin(a)-y_)
end
end
off+=0.025
y=y_+sin(off)*2.5
end
}
--- </fruitrain> ---
fly_fruit={
check_fruit=true,
init=function(_ENV)
start=y
step=0.5
sfx_delay=8
end,
update=function(_ENV)
--fly away
if has_dashed then
if sfx_delay>0 then
sfx_delay-=1
if sfx_delay<=0 then
_g.sfx_timer=20
sfx(10)
end
end
spd.y=appr(spd.y,-3.5,0.25)
if y<-16 then
destroy_object(_ENV)
end
-- wait
else
step+=0.05
spd.y=sin(step)*0.5
end
-- collect
if player_here() then
--- <fruitrain> ---
init_smoke(-6)
init_smoke(6)
local f=init_object(fruit,x,y,10) --if this happens to be in the exact location of a different fruit that has already been collected, this'll cause a crash
--TODO: fix this if needed
f.fruit_id=fruit_id
fruit.update(f)
--- </fruitrain> ---
destroy_object(_ENV)
end
end,
draw=function(_ENV)
spr(10,x,y)
for ox=-6,6,12 do
spr((has_dashed or sin(step)>=0) and 12 or y>start and 14 or 13,x+ox,y-2,1,1,ox==-6)
end
end
}
lifeup={
init=function(_ENV)
spd.y=-0.25
duration=30
flash=0
outline=false
_g.sfx_timer=20
sfx(9)
end,
update=function(_ENV)
duration-=1
if duration<=0 then
destroy_object(_ENV)
end
end,
draw=function(_ENV)
flash+=0.5
--<fruitrain>--
?sprite<=5 and sprite.."000" or "1UP",x-4,y-4,7+flash%2
--<fruitrain>--
end
}
key_door_used={}
key={
init=function(_ENV)
if key_door_used[fruit_id] then
destroy_object(_ENV)
end
y_=y
off=0
tx=x
ty=y
timer=0
end,
update=function(_ENV)
if timer>0 then
timer-=1
if timer==0 then
target.timer=1
init_smoke()
destroy_object(_ENV)
end
elseif not target then
local hit=player_here()
if hit then
hit.key_count+=1
--follow=true
target=#fruitrain==0 and hit or fruitrain[#fruitrain]
r=#fruitrain==0 and 12 or 8
add(fruitrain,_ENV)
key_door_used[fruit_id]=true
end
else
tx+=0.2*(target.x+target.hitbox.w/2-hitbox.w/2-tx)
ty+=0.2*(target.y+target.hitbox.h/2-hitbox.h/2-ty) --target center, which matters (more) for doors
local a=atan2(x-tx,y_-ty)
local k=(x-tx)^2+(y_-ty)^2 > r^2 and 0.2 or 0.1
x+=k*(tx+r*cos(a)-x)
y_+=k*(ty+r*sin(a)-y_)
if target.type==keydoor and (x-target.x-4)^2+(y-target.y-4)^2<5 then
x,y_,timer=target.x+4,target.y+4,20
end
end
off+=0.025
y=y_+sin(off)*2.5
sprite=65.5+sin(frames/30)
if frames==18 then
flip.x=not flip.x
end
end,
draw=function(_ENV)
if timer>10 then
rectfill(x+3,y_+2,x+4,y_+5,10)
elseif timer>0 then
rectfill(x+2,y_+4,x+5,y_+5,10)
else
spr(sprite,x,y,0.875,1,flip.x,flip.y)
if flr(sprite)==66 and flip.x then
line(x+3,y+5,x+3,y+7,9)
end
end
end
}
keydoor={
layer=0, --might cause visual problems? idk lol
init=function(_ENV)
if key_door_used[fruit_id] then
destroy_object(_ENV)
end
hitbox=rectangle(0,0,16,16)
solid_obj=true
timer=0
end,
update=function(_ENV)
if timer>0 then
collideable=false
timer+=1
if timer==12 then
init_smoke(-8,0)
init_smoke(-8,8)
init_smoke(16,0)
init_smoke(16,8)
destroy_object(_ENV)
end
elseif not has_key then
hitbox=rectangle(-16,-16,48,48)
local hit=player_here()
if hit and hit.key_count>0 then
hit.key_count-=1
for i,f in ipairs(fruitrain) do
if f.type==key then
local p=fruitrain[i+1] or {}
p.target,p.r=f.target,f.r
del(fruitrain,f)
key_door_used[fruit_id]=true
f.target,f.r=_ENV,0
has_key=true
break
end
end
end
hitbox=rectangle(0,0,16,16)
end
end,
draw=function(_ENV)
spr(80,x-timer\3,y,1,2)
spr(81,x+8+timer\3,y,1,2)
end
}
sawblade={
layer=0,
init=function(_ENV)
hitbox=rectangle(2,2,12,12)
axis=sprite==112 and "x" or "y"
r=_ENV[axis]
while axis=="x" and r<lvl_pw and not fget(tile_at(r\8,y\8),0) or
axis=="y" and r<lvl_ph and not fget(tile_at(x\8,r\8),0) do
r+=8
end
_ENV[axis]-=4
l=_ENV[axis]
r-=12
end,
update=function(_ENV)
if _ENV[axis]>=r then
dir=-1
elseif _ENV[axis]<=l then
dir=1
end
spd[axis]=appr(spd[axis],2*dir,0.4)
local hit=player_here()
if hit then
kill_player(hit)
end
end,
draw=function(_ENV)
for i=0,3 do
spr(abs(2*_ENV[axis]-l-r)<10 and 113 or 112,x+(i%2)*8,y+i\2*8,1,1,i%2!=0,i>1)
end
end
}
--<red_bubble>--
red_bubble_particle={
layer=0,
init=function(_ENV)
outline=false
spd=vector(0.3-rnd(0.3),0.1)
x+=-1+rnd(2)
y+=-1+rnd(2)
flip=vector(maybe(),maybe())
end,
update=function(_ENV)
sprite+=rnd(0.2)
if sprite>=29 then
destroy_object(_ENV)
end
end,
draw=function(_ENV)
pal(7,14)
draw_obj_sprite(_ENV)
pal()
end
}
red_bubble={
init=function(_ENV)
t=0
st=0
timer=0
shake=0
dead_timer=0
hitbox=rectangle(0,0,12,12)
outline=false --maybe add an extra black outline, or remove this?
startx,starty=x,y
end,
hide=function(_ENV)
invisible=true
timer=0
x,y=startx,starty
spd=vector(0,0)
rem=vector(0,0)
active=false
init_smoke()
end,
update=function(_ENV)
local maxspd=3.5
local hit=player_here()
if hit and not invisible then
hit.move(-hit.x+x+1,-hit.y+y+1,1)
if hit.x!=x+1 or hit.y!=y+1 then
hit.invisible=false
hit.init_smoke()
hit.spd.x=sign(spd.x)
hit.spd.y=sign(spd.y)
hit.djump=max_djump
red_bubble.hide(_ENV)
else
active=true
hit.invisible=true
hit.spd=vector(0,0)
hit.rem=vector(0,0)
hit.dash_time=0
hit.djump=0
if timer==0 then
timer=1
shake=5
elseif timer<15 then
timer+=1
if timer==15 then
init_smoke()
local diry=btn(⬆️) and -1 or btn(⬇️) and 1 or 0
local dirx=btn(➡️) and 1 or btn(⬅️) and -1 or diry==0 and (hit.flip.x and -1 or 1) or 0
local k=maxspd/sqrt(dirx^2+diry^2)
spd=vector(dirx*k,diry*k)
end
else
init_object(red_bubble_particle,x,y,26)
end
if btnp(❎) then
if timer<15 then
timer=14
else
hit.invisible=false
hit.djump=max_djump
hit.do_dash=true
red_bubble.hide(_ENV)
end
end
end
elseif invisible then
dead_timer+=1
if dead_timer==60 then
dead_timer=0
invisible=false
init_smoke()
end
elseif active then
red_bubble.hide(_ENV)
end
end,
draw=function(_ENV)
t+=0.05
local x,y,t=x,y,t
if shake>0 then
shake-=1
x+=rnd(2)-1
y+=rnd(2)-1
end
local sx=sin(t)>=0.5 and 1 or 0
local sy=sin(t)<-0.5 and 1 or 0
for f in all({ovalfill,oval}) do
f(x-2-sx,y-2-sy,x+9+sx,y+9+sy,f==oval and 7 or 8)
end
if active then
st+=1
st%=8
pal(8,2)
pal(15,2)
pal(1,2)
pal(3,2)
pal(7,8)
local c=flr(st)
if abs(spd.x)+abs(spd.y)==0 then
spr(1,x-1,y-1)
st=-1
else
spr(1,x+(split"-1,0,1,1,1,0,-1,-1")[st+1],y+(split"-1,-1,-1,0,1,1,1,0")[st+1]) --spinny stuff
end
pal()
end
for dx=2,5 do
local _t=(5*t+3*dx)%8
local bx=sgn(dx-4)*round(sin(_t/16))
rectfill(x+dx-bx,y+8-_t,x+dx-bx,y+8-_t,9)
end
rectfill(x+5+sx,y+1-sy,x+6+sx,y+2-sy,7)
end
}
--</red_bubble>--
dash_switch={
layer=0,
init=function(_ENV)
solid_obj=true
ogy=y
ogx=x
diry=sprite==68 and 1 or sprite==69 and -1 or 0
dirx=sprite==83 and -1 or sprite==99 and 1 or 0
hitbox=diry==0 and rectangle(dirx==1 and 3 or 0,0,5,10) or rectangle(0,3,10,5)
t=0
end,
update=function(_ENV)
if not active then
local hit=check(player,-dirx,-diry) or check(theo_crystal,-dirx,-diry)
if hit then
--<theo_crystal> --
if hit.type==theo_crystal or (hit.dash_effect_time>3 and
(diry==0 or sign(hit.dash_target_y)==diry) and