-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.p8
1439 lines (1299 loc) · 49.2 KB
/
main.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 18
__lua__
-- beeeeeees
-- by us
-- ** technical ** --
function abs_box(o)
-- absolute box for object o
local box = {}
box.x1 = o.box.x1 + o.x
box.y1 = o.box.y1 + o.y
box.x2 = o.box.x2 + o.x
box.y2 = o.box.y2 + o.y
return box
end
function iou(o1,o2)
-- intersection over union of two objects
-- return percentage in [0,1], 1 is perfect match
local box_o1 = abs_box(o1)
local box_o2 = abs_box(o2)
-- x,y coordinates of intersection
local x1 = max(box_o1.x1,box_o2.x1)
local y1 = max(box_o1.y1,box_o2.y1)
local x2 = min(box_o1.x2,box_o2.x2)
local y2 = min(box_o1.y2,box_o2.y2)
-- area of intersection
local inter_area = max(0, x2 - x1 + 1) * max(0, y2 - y1 + 1)
-- area of both boxes
local o1_area = (box_o1.x2 - box_o1.x1 + 1) * (box_o1.y2 - box_o1.y1 + 1)
local o2_area = (box_o2.x2 - box_o2.x1 + 1) * (box_o2.y2 - box_o2.y1 + 1)
return inter_area / (o1_area + o2_area - inter_area)
end
function debug_infos(x,y)
camera() -- reset camera before drawing
if(btn(0)) then print("⬅️",x,y+6,7) end
if(btn(1)) then print("➡️",x+16,y+6,7) end
if(btn(2)) then print("⬆️",x+8,y,7) end
if(btn(3)) then print("⬇️",x+8,y+6,7) end
if(btn(4)) then print("🅾️",x+16,y,7) end
if(btn(5)) then print("❎",x,y,7) end
print("tmr:"..p.tmr,x,y+16,7)
print("p.x:"..p.x,x,y+24,7)
print("p.y:"..p.y,x,y+32,7)
end
-- ** bees - general ** --
function player_init()
p={
name="barry",
tot_pln=0, -- cumulative pollen
cur_pln=0, -- current pollen
max_pln=10, -- max usable pollen before slowdown in speed
cur_spd=3, -- speed
max_spd=3,
x=64, -- x,y coordinate, RELATIVE TO THE SCREEN
y=64,
box={x1=1,y1=1,x2=14,y2=14}, -- collision box
sp=0, -- current sprite
sp_st=0, -- first sprite of the animation
sp_sz=2, -- sprite size
flp_x=false, -- should the sprite be flipped horizontally
flp_y=false, -- should the sprite be flipped vertically
action=false, -- can't move if action is true
tmr=0 -- internal timer
}
end
function player_draw()
spr(p.sp,p.x,p.y,p.sp_sz,p.sp_sz,p.flp_x,p.flp_y)
end
function bees_init()
bees={}
add(bees,{
name="beeatrice", -- buzz, beenedict, beelzebub, beeyonce, obee wan, rubee, beely, kirbee, ...
tot_pln=0, -- cumulative pollen
cur_pln=0, -- current pollen
max_pln=10, -- max usable pollen before slowdown in speed
cur_spd=3, -- speed
max_spd=3,
x=64, -- x,y coordinate, RELATIVE TO THE SCREEN
y=64,
box={x1=1,y1=1,x2=14,y2=14}, -- collision box
sp=10, -- current sprite
sp_st=10, -- first sprite of the animation
sp_sz=2, -- sprite size
flp_x=false, -- should the sprite be flipped horizontally
flp_y=false, -- should the sprite be flipped vertically
action=false, -- can't move if action is true
tmr=0 -- internal timer
})
add(bees,{
name="beertrand", -- buzz, beenedict, beelzebub, beeyonce, obee wan, rubee, beely, kirbee, ...
tot_pln=0, -- cumulative pollen
cur_pln=0, -- current pollen
max_pln=10, -- max usable pollen before slowdown in speed
cur_spd=3, -- speed
max_spd=3,
x=64, -- x,y coordinate, RELATIVE TO THE SCREEN
y=64,
box={x1=1,y1=1,x2=14,y2=14}, -- collision box
sp=10, -- current sprite
sp_st=10, -- first sprite of the animation
sp_sz=2, -- sprite size
flp_x=false, -- should the sprite be flipped horizontally
flp_y=false, -- should the sprite be flipped vertically
action=false, -- can't move if action is true
tmr=0 -- internal timer
})
add(bees,{
name="beenedict", -- buzz, beenedict, beelzebub, beeyonce, obee wan, rubee, beely, kirbee, ...
tot_pln=0, -- cumulative pollen
cur_pln=0, -- current pollen
max_pln=10, -- max usable pollen before slowdown in speed
cur_spd=3, -- speed
max_spd=3,
x=64, -- x,y coordinate, RELATIVE TO THE SCREEN
y=64,
box={x1=1,y1=1,x2=14,y2=14}, -- collision box
sp=10, -- current sprite
sp_st=10, -- first sprite of the animation
sp_sz=2, -- sprite size
flp_x=false, -- should the sprite be flipped horizontally
flp_y=false, -- should the sprite be flipped vertically
action=false, -- can't move if action is true
tmr=0 -- internal timer
})
end
-- ** actual game ** --
function _init()
player_init()
bees_init()
-- text boxes
dtb_init()
menu_init()
--story_init()
--_update=story_update
--_draw=story_draw
end
-->8
-- menu and intro
-- ** menu ** --
function menu_init()
dt=0
music(0)
_update=menu_update
_draw=menu_draw
end
function menu_update()
dt+=1
if(btnp(4)) then
intro_init()
end
end
function menu_draw()
cls()
spr(128,56,0,2,2)
spr(130,32,16,8,2)
print("bee-hold ,the queen",26,32,9)
print("press 🅾️ to start",28,60,6)
if(dt<15) then
print(" 🅾️",29,61,9)
else
print(" 🅾️",28,60,9)
end
if(dt>30) then
dt=0
end
print("art:",56,86,2)
print("{heaspery,sarapeljamais}.itch.io",0,93,2)
print("code:",54,100,2)
print("astache.itch.io",34,107,2)
print("music:",52,114,2)
print("@louismerlin",40,121,2)
end
-- ** intro ** --
function intro_init()
intro_msg_set(1)
_update=nil
_draw=intro_draw
end
function intro_draw()
cls()
if(intro_msg_draw(4, 4) == "empty") then
cls()
_update=dtb_update
_draw=dtb_draw
dtb_disp("⬅️,➡️,⬆️,⬇️:move; ❎:action (forage, talk, ..); 🅾️:choose/end dialogue",exploration_init)
end
end
-->8
-- exploration
-- ** exploration - initialisation ** --
function bee_exploration_init(bee)
-- each bee will start at a random position, with a random pollen quantity
bee.x=flr(rnd(map_width-4 - p.sp_sz * 8)+4) -- x,y coordinates
bee.y=flr(rnd(map_height-4 - p.sp_sz * 8)+4)
bee.cur_pln=flr(rnd(30)) -- could be improved with a nice gaussian
end
function flowers_init(nbr)
-- create a number of flowers between 1 and nbr.
flowers={}
for i=1,nbr do
add(flowers,{
x=flr(rnd(map_width-32)+16), -- x,y coordinates
y=flr(rnd(map_height-32)+10),
box={x1=2,y1=3,x2=29,y2=29}, -- collision box
sp=74, -- current sprite
sp_bs_clr=13, -- base color, used to change the color
sp_clr=13,--flr(rnd(4)+13), -- final color
sp_sz=4, -- sprite size
pln=flr(rnd(6)) -- pollen quantity
})
end
end
function hive_init()
-- put the ruche in a random place
-- yes i know it's hive in english gimme a break
hive={
x=flr(rnd(map_width/3)+map_width/3), -- x,y coordinates
y=flr(rnd(map_height/3)+map_height/3),
box={x1=10,y1=14,x2=18,y2=22}, -- collision box, centered on the door
sp=70, -- current sprite
sp_sz=4, -- sprite size
pln=0 -- pollen quantity
}
end
function exploration_init()
-- map
map_width=128*3
map_height=128*3
-- flowers
flowers_init(15)
-- hive
hive_init()
-- reset internal timer and set first sprite
p.sp_st=0
p.tmr=0
-- player starts at the hive
p.x=hive.x+hive.sp_sz*4
p.y=hive.y+hive.sp_sz*4
-- other bees start wherever
foreach(bees,bee_exploration_init)
-- camera coordinates for the map
cam_x=p.x-64
cam_y=p.y-64
-- percentage of match between two objects if collision
tlrnc=0.10
-- reset internal timer
p.tmr=0
_update=exploration_update
_draw=exploration_draw
end
-- ** exploration - updating ** --
function player_exploration_update()
p.tmr+=1 -- internal timer. 30fps
if(not p.action) then
-- check for bees: save current position
local px = p.x
local py = p.y
-- animation
if(p.tmr == 10) then
p.sp = p.sp_st
end
if(p.tmr >= 20) then
p.sp += p.sp_sz
p.tmr = 0 -- restart timer
end
-- actions
-- left
if(btn(0)) then
p.sp_st=32
p.flp_x=true
if(cam_x > 0 and p.x-cam_x<64) then
cam_x-=p.cur_spd
p.x-=p.cur_spd
else
if(p.x > 4) then
p.x-=p.cur_spd
end
end
end
-- right
if(btn(1)) then
p.sp_st=32
p.flp_x=false
if(cam_x < map_width-128 and p.x-cam_x>64) then
cam_x+=p.cur_spd
p.x+=p.cur_spd
else
if(p.x < map_width-4 - p.sp_sz * 8) then
p.x+=p.cur_spd
end
end
end
-- up
if(btn(2)) then
p.sp_st=0
p.flp_y=false
if(cam_y > 0 and p.y-cam_y<64) then
cam_y-=p.cur_spd
p.y-=p.cur_spd
else
if(p.y > 4) then
p.y-=p.cur_spd
end
end
end
-- down
if(btn(3)) then
p.sp_st=0
p.flp_y=true
if(cam_y < map_height-128 and p.y-cam_y>64) then
cam_y+=p.cur_spd
p.y+=p.cur_spd
else
if(p.y < map_height-4 - p.sp_sz * 8) then
p.y+=p.cur_spd
end
end
end
-- action (X) -- todo talk w/ bees
if(btnp(5)) then
p.action=true -- lock the player
p.tmr = 0 -- restart timer
end
-- check for bees: if there is a bee, then...
for b in all(bees) do
if(check_collision_bee(b)) then
-- back to old position
p.x=px
p.y=py
end
end
else
-- shall we talk?
local talk=false
for b in all(bees) do
b.box.x1-=5
b.box.y1-=5
b.box.x2+=5
b.box.y2+=5
if(check_collision_bee(b)) then
talk=true
talk_to_bee(b)
end
b.box.x1+=5
b.box.y1+=5
b.box.x2-=5
b.box.y2-=5
end
if(not talk) then
get_down()
end
end
-- pollen
p.cur_spd=p.max_spd-flr(p.cur_pln/(p.max_pln + 1))
end
bees_hello = {"hey!","greetings.","hi!","howdy!","bonjour!","good day."}
bees_ok = {"all is right!","you okay?","i'm fine!","all the best for you.","all hail the queen!","la probabilité de voir ce message est de 0.005%."}
bees_ciao = {"see you!","ciao!","au revoir.","see you soon!","thanks."}
function talk_to_bee(bee)
dtb_disp(bee.name..": "..bees_hello[1+flr(rnd(#bees_hello))])
if(bee.cur_pln > bee.max_pln) then
dtb_disp(bee.name..": i have too much pollen!")
dtb_disp(bee.name..": can you take me some?")
if(p.cur_pln<p.max_pln) then
local qt=min(p.max_pln-p.cur_pln,bee.cur_pln-bee.max_pln)
bee.cur_pln-=qt
p.cur_pln+=qt
end
else
if(bee.cur_pln < bee.max_pln) then
dtb_disp(bee.name..": i don't have enough pollen...")
dtb_disp(bee.name..": do you have any?")
if(p.cur_pln>0) then
local qt=min(p.cur_pln,bee.max_pln-bee.cur_pln)
bee.cur_pln+=qt
p.cur_pln-=qt
end
else
dtb_disp(bee.name..": "..bees_ok[1+flr(rnd(#bees_ok))])
end
end
dtb_disp(bee.name..": "..bees_ciao[1+flr(rnd(#bees_ciao))])
p.action=false
end
function choice_take()
p.action=false
end
function get_down()
-- basically an animation with black magic...
if(p.tmr == 15) then
sfx(13)
p.sp = p.sp_st + 2 * p.sp_sz
end
if(p.tmr == 30) then
p.sp += p.sp_sz
end
if(p.tmr == 45) then
p.sp += p.sp_sz
end
if(p.tmr == 75) then
-- first try to get into hive
if(not get_into_hive()) then
-- if not into hive, try to collect pollen
for f in all(flowers) do
if(check_flower(f)) then
-- todo break, idk how to do that
end
end
end
end
if(p.tmr == 120) then
p.sp -= p.sp_sz
end
if(p.tmr == 135) then
p.sp -= p.sp_sz
end
if(p.tmr == 150) then
p.sp -= p.sp_sz
p.action=false
end
end
function check_collision_bee(bee)
if(iou(p,bee) >= .1*tlrnc) then
return true
else
return false
end
end
function get_into_hive()
if(iou(p,hive) >= 2*tlrnc) then
story_init()
return true
else
return false
end
end
function check_flower(f)
if(iou(p,f) >= tlrnc) then
p.cur_pln+=f.pln
f.pln = 0
return true
else
return false
end
end
function bee_exploration_update(bee)
-- todo random mouvement
-- animation
-- internal timer
bee.tmr+=1
if(bee.tmr == 10) then
bee.sp = bee.sp_st
end
if(bee.tmr >= 20) then
bee.sp += bee.sp_sz
bee.tmr = 0 -- restart timer
end
end
function exploration_update()
player_exploration_update()
foreach(bees,bee_exploration_update)
-- text boxes
dtb_update()
end
-- ** exploration - drawing ** --
function bee_draw(bee)
spr(bee.sp,bee.x,bee.y,bee.sp_sz,bee.sp_sz,bee.flp_x,bee.flp_y)
end
function hive_draw()
spr(hive.sp,hive.x,hive.y,hive.sp_sz,hive.sp_sz)
end
function flower_draw(f)
-- general flower color
pal(f.sp_bs_clr,f.sp_clr)
-- if the flower is empty, the pistil is not shown
if(f.pln == 0) then
pal(9,1)
end
-- the actual flower
spr(f.sp,f.x,f.y,f.sp_sz,f.sp_sz)
pal()
if(f.pln > 0) then
for i=1,f.pln do
-- beautiful pollen bits...
modificator_x=(6+(i*17))%(f.sp_sz*8)
modificator_y=(7+(i*41))%(f.sp_sz*8)
pset(f.x+modificator_x,f.y+modificator_y,9)
pset(1+f.x+modificator_x,f.y+modificator_y,9)
pset(f.x+modificator_x,1+f.y+modificator_y,9)
pset(1+f.x+modificator_x,1+f.y+modificator_y,9)
end
end
end
function exploration_draw()
-- first reset the fucker
cls()
-- set the camera to the current location
camera(cam_x, cam_y)
-- draw the entire map
for i=0,map_width/16 do
for j=0,map_width/16 do
map(24, 0, 16*i, 16*j, 2, 2)
end
end
-- hive
hive_draw()
-- flowers
foreach(flowers,flower_draw)
-- bees
foreach(bees,bee_draw)
-- player
player_draw()
-- reset camera
camera()
-- pollen
draw_pollen_sphere(2,1,p.cur_pln,p.max_pln)
-- textboxes
dtb_draw()
end
function draw_pollen_sphere(x,y,curr,maxx)
if(curr < 0.25*maxx) then
palt(9,true)
else
palt(9,false)
end
spr(84,x,y+8,2,1)
if(curr < 0.75*maxx) then
palt(9,true)
else
palt(9,false)
end
spr(68,x,y,2,1)
palt(9,false)
end
-->8
-- story
-- ** story initialisation ** --
function story_init()
-- map
map_width=128*1.5
map_height=128
-- camera coordinates for the map
cam_x=0
cam_y=0
-- reset internal timer and set first sprite
p.flp_x=false
p.flp_y=false
p.sp_st=14
p.tmr=0
-- start position
p.x=0
p.y=74
-- pollen!
-- player
p.tot_pln+=p.cur_pln
hive.pln+=p.cur_pln
p.cur_pln=0
-- bees
for b in all(bees) do
if(b.cur_pln > b.max_pln) then
-- the bee did not get here...
b.cur_pln=0
end
b.tot_pln+=b.cur_pln
hive.pln+=b.cur_pln
b.cur_pln=0
end
queen_status()
_update=story_update
_draw=story_draw
end
function queen_status()
if(hive.pln<20) then
dtb_disp("the queen seems to be in really bad shape...")
dtb_disp("we need to forage more!")
end
if(hive.pln>=20 and hive.pln<40) then
dtb_disp("the bees went back to work.")
dtb_disp("maybe there is hope.")
end
if(hive.pln>=40 and hive.pln<60) then
dtb_disp("we're going to make it... probably!")
end
if(hive.pln>=60 and hive.pln<80) then
dtb_disp("more pollen, more pollen...")
end
if(hive.pln>=80) then
dtb_disp("the queen is back! hooray")
end
end
-- ** story updating ** --
function player_story_update()
p.tmr+=1 -- internal timer. 30fps
-- animation
if(p.tmr == 10) then
p.sp = p.sp_st
end
if(p.tmr >= 20) then
p.sp = 46
p.tmr = 0 -- restart timer
end
-- actions
-- left
if(btn(0)) then
p.flp_x=true
if(cam_x > 0 and p.x-cam_x<64) then
cam_x-=p.cur_spd
p.x-=p.cur_spd
else
p.x-=p.cur_spd
if(p.x < -8) then
exploration_init()
end
end
end
-- right
if(btn(1)) then
p.flp_x=false
if(cam_x < map_width-128 and p.x-cam_x>64) then
cam_x+=p.cur_spd
p.x+=p.cur_spd
else
if(p.x < map_width-4-8-16 - p.sp_sz * 8) then
p.x+=p.cur_spd
end
end
end
-- action (X) -- todo talk w/ bees
if btnp(5) then
--p.action=true -- lock the player
p.tmr = 0 -- restart timer
end
-- pollen
p.cur_spd=p.max_spd-flr(p.cur_pln/(p.max_pln + 1))
end
function story_update()
player_story_update()
-- text boxes
dtb_update()
end
-- ** story drawing ** --
function story_draw()
cls()
-- set the camera to the current location
camera(cam_x, cam_y)
-- draw the entire map -- todo
map(0, 0, 0, 0, 32, 16)
-- bee
player_draw()
-- pollen...
draw_pollen_sphere(17,38,min(hive.pln,20),20)
draw_pollen_sphere(33,6,min(hive.pln,40),40)
draw_pollen_sphere(65,38,min(hive.pln,60),60)
draw_pollen_sphere(113,38,min(hive.pln,80),80)
draw_pollen_sphere(129,6,min(hive.pln,100),100)
if(hive.pln<80) then
spr(64,22*8,8*8,2,2)
else
spr(66,22*8,8*8,2,2)
end
-- reset camera
camera()
-- text boxes
dtb_draw()
end
-->8
-- textboxes
-- code courtesy of oli414/bbs
-- call this before you start using dtb.
-- optional parameter is the number of lines that are displayed. default is 3.
function dtb_init(numlines)
dtb_queu={}
dtb_queuf={}
dtb_numlines=3
if numlines then
dtb_numlines=numlines
end
_dtb_clean()
end
-- this will add a piece of text to the queu. the queu is processed automatically.
function dtb_disp(txt,callback)
local lines={}
local currline=""
local curword=""
local curchar=""
local upt=function()
if #curword+#currline>29 then
add(lines,currline)
currline=""
end
currline=currline..curword
curword=""
end
for i=1,#txt do
curchar=sub(txt,i,i)
curword=curword..curchar
if curchar==" " then
upt()
elseif #curword>28 then
curword=curword.."-"
upt()
end
end
upt()
if currline~="" then
add(lines,currline)
end
add(dtb_queu,lines)
if callback==nil then
callback=0
end
add(dtb_queuf,callback)
end
-- functions with an underscore prefix are ment for internal use, don't worry about them.
function _dtb_clean()
dtb_dislines={}
for i=1,dtb_numlines do
add(dtb_dislines,"")
end
dtb_curline=0
dtb_ltime=0
end
function _dtb_nextline()
dtb_curline+=1
for i=1,#dtb_dislines-1 do
dtb_dislines[i]=dtb_dislines[i+1]
end
dtb_dislines[#dtb_dislines]=""
sfx(2)
end
function _dtb_nexttext()
if dtb_queuf[1]~=0 then
dtb_queuf[1]()
end
del(dtb_queuf,dtb_queuf[1])
del(dtb_queu,dtb_queu[1])
_dtb_clean()
sfx(2)
end
-- make sure that this function is called each update.
function dtb_update()
if #dtb_queu>0 then
if dtb_curline==0 then
dtb_curline=1
end
local dislineslength=#dtb_dislines
local curlines=dtb_queu[1]
local curlinelength=#dtb_dislines[dislineslength]
local complete=curlinelength>=#curlines[dtb_curline]
if complete and dtb_curline>=#curlines then
if btnp(4) then
_dtb_nexttext()
return
end
elseif dtb_curline>0 then
dtb_ltime-=1
if not complete then
if dtb_ltime<=0 then
local curchari=curlinelength+1
local curchar=sub(curlines[dtb_curline],curchari,curchari)
dtb_ltime=1
if curchar~=" " then
sfx(0)
end
if curchar=="." then
dtb_ltime=6
end
dtb_dislines[dislineslength]=dtb_dislines[dislineslength]..curchar
end
if btnp(4) then
dtb_dislines[dislineslength]=curlines[dtb_curline]
end
else
--if btnp(4) then
_dtb_nextline()
--end
end
end
end
end
-- make sure to call this function everytime you draw.
function dtb_draw()
-- reset camera
camera()
if #dtb_queu>0 then
local dislineslength=#dtb_dislines
local offset=0
if dtb_curline<dislineslength then
offset=dislineslength-dtb_curline
end
rectfill(2,125-dislineslength*8,125,125,0)
if dtb_curline>0 and #dtb_dislines[#dtb_dislines]==#dtb_queu[1][dtb_curline] then
print("\x8e",118,120,1)
end
for i=1,dislineslength do
print(dtb_dislines[i],4,i*8+119-(dislineslength+offset)*8,7)
end
end
-- camera is back
camera(cam_x, cam_y)
end
-->8
-- introduction
-- code courtesy of shooting★/bbs
--★ is used as my signature.
--[[
text codes:
$u1 = underline text (0 for
no underline)
$b## = border color, ##= a
number, 0-15
$o## = outline color
$c## = text color
$d## = delay extra (0-99)
if more delay is
needed, use $f##
and create a custom
fx for it.
$f## = special effects
for any of these, you can use
xx instead of a number to
reset it to default (based
on the default config you
have set up)
alternatively, you can use
16 to set it to nil and
remove it.
]]--
--==configurations==--
--[[
configure your defaults
here
--]]
★intro_msg_cnf = {
--default color 1
15,
--default highlight 2
nil,
--default outline 3
1,
--letter spacing 4
4,
--new line spacing 5
7,
--blip sound 6
14,
--next msg sound 7
13,
---------------------
--skip text/fast finish
--button 8
4,
--next action character
'🅾️',
--next action character color
9
}
--[[
standard variables,dont edit
--]]
★intro_msg_i=1
★intro_msg_t=0
★intro_msg_del=1
★intro_msg_cur=1
--==edit special fx here==--
--[[
special effects can be
applied to all text after
the fx code: $fid
where id=a number starting
with 1. in this sample,
$f01 gives a wavy text
effect. its auto-indexed,
so make sure you comment
similar to what i did
to avoid confusion.