forked from omgmog/lazydevs-pico8-roguelike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpork.p8
2205 lines (1969 loc) · 63.8 KB
/
pork.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 16
__lua__
function _init()
t=0
shake=0
dpal=explodeval("0,1,1,2,1,13,6,4,4,9,3,13,1,13,14")
dirx=explodeval("-1,1,0,0,1,1,-1,-1")
diry=explodeval("0,0,-1,1,-1,1,1,-1")
itm_name=explode("butter knife,cheese knife,paring knife,utility knife,chef's knife,meat cleaver,paper apron,cotton apron,rubber apron,leather apron,chef's apron,butcher's apron,food 1,food 2,food 3,food 4,food 5,food 6,spork,salad fork,fish fork,dinner fork")
itm_type=explode("wep,wep,wep,wep,wep,wep,arm,arm,arm,arm,arm,arm,fud,fud,fud,fud,fud,fud,thr,thr,thr,thr")
itm_stat1=explodeval("1,2,3,4,5,6,0,0,0,0,1,2,1,2,3,4,5,6,1,2,3,4")
itm_stat2=explodeval("0,0,0,0,0,0,1,2,3,4,3,3,0,0,0,0,0,0,0,0,0,0")
itm_minf=explodeval("1,2,3,4,5,6,1,2,3,4,5,6,1,1,1,1,1,1,1,2,3,4")
itm_maxf=explodeval("3,4,5,6,7,8,3,4,5,6,7,8,8,8,8,8,8,8,4,6,7,8")
itm_desc=explode(",,,,,,,,,,,, heals, heals a lot, increases hp, stuns, is cursed, is blessed,,,,")
mob_name=explode("player,slime,melt,shoggoth,mantis-man,giant scorpion,ghost,golem,drake")
mob_ani=explodeval("240,192,196,200,204,208,212,216,220")
mob_atk=explodeval("1,1,2,1,2,3,3,5,5")
mob_hp=explodeval("5,1,2,3,3,4,5,14,8")
mob_los=explodeval("4,4,4,4,4,4,4,4,4")
mob_minf=explodeval("0,1,2,3,4,5,6,7,8")
mob_maxf=explodeval("0,3,4,5,6,7,8,8,8")
mob_spec=explode(",,,spawn?,fast?,stun,ghost,slow,")
crv_sig=explodeval("255,214,124,179,233")
crv_msk=explodeval("0,9,3,12,6")
free_sig=explodeval("0,0,0,0,16,64,32,128,161,104,84,146")
free_msk=explodeval("8,4,2,1,6,12,9,3,10,5,10,5")
wall_sig=explodeval("251,233,253,84,146,80,16,144,112,208,241,248,210,177,225,120,179,0,124,104,161,64,240,128,224,176,242,244,116,232,178,212,247,214,254,192,48,96,32,160,245,250,243,249,246,252")
wall_msk=explodeval("0,6,0,11,13,11,15,13,3,9,0,0,9,12,6,3,12,15,3,7,14,15,0,15,6,12,0,0,3,6,12,9,0,9,0,15,15,7,15,14,0,0,0,0,0,0")
debug={}
startgame()
end
function _update60()
t+=1
_upd()
dofloats()
dohpwind()
end
function _draw()
doshake()
_drw()
drawind()
drawlogo()
--fadeperc=0
checkfade()
--★
cursor(4,4)
color(8)
for txt in all(debug) do
print(txt)
end
end
function startgame()
poke(0x3101,194)
music(0)
tani=0
fadeperc=1
buttbuff=-1
logo_t=240
logo_y=35
skipai=false
win=false
winfloor=9
--★
mob={}
dmob={}
p_mob=addmob(1,1,1)
p_t=0
inv,eqp={},{}
makeipool()
foodnames()
--takeitem(17)
wind={}
float={}
talkwind=nil
hpwind=addwind(5,5,28,13,{})
thrdx,thrdy=0,-1
_upd=update_game
_drw=draw_game
st_steps,st_kills,st_meals,st_killer=0,0,0,""
genfloor(0)
end
-->8
--updates
function update_game()
if talkwind then
if getbutt()==5 then
sfx(53)
talkwind.dur=0
talkwind=nil
end
else
dobuttbuff()
dobutt(buttbuff)
buttbuff=-1
end
end
function update_inv()
--inventory
if move_mnu(curwind) and curwind==invwind then
showhint()
end
if btnp(4) then
sfx(53)
if curwind==invwind then
_upd=update_game
invwind.dur=0
statwind.dur=0
if hintwind then
hintwind.dur=0
end
--★
elseif curwind==usewind then
usewind.dur=0
curwind=invwind
end
elseif btnp(5) then
sfx(54)
if curwind==invwind and invwind.cur!=3 then
showuse()
--★
elseif curwind==usewind then
-- use window confirm
triguse()
end
end
end
function update_throw()
local b=getbutt()
if b>=0 and b<=3 then
thrdx=dirx[b+1]
thrdy=diry[b+1]
end
if b==4 then
_upd=update_game
elseif b==5 then
throw()
end
end
function move_mnu(wnd)
local moved=false
if btnp(2) then
sfx(56)
wnd.cur-=1
moved=true
elseif btnp(3) then
sfx(56)
wnd.cur+=1
moved=true
end
wnd.cur=(wnd.cur-1)%#wnd.txt+1
return moved
end
function update_pturn()
dobuttbuff()
p_t=min(p_t+0.125,1)
if p_mob.mov then
p_mob:mov()
end
if p_t==1 then
_upd=update_game
if trig_step() then return end
if checkend() and not skipai then
doai()
end
skipai=false
end
end
function update_aiturn()
dobuttbuff()
p_t=min(p_t+0.125,1)
for m in all(mob) do
if m!=p_mob and m.mov then
m:mov()
end
end
if p_t==1 then
_upd=update_game
if checkend() then
if p_mob.stun then
p_mob.stun=false
doai()
end
end
end
end
function update_gover()
if btnp(❎) then
sfx(54)
fadeout()
startgame()
end
end
function dobuttbuff()
if buttbuff==-1 then
buttbuff=getbutt()
end
end
function getbutt()
for i=0,5 do
if btnp(i) then
return i
end
end
return -1
end
function dobutt(butt)
if butt<0 then return end
if logo_t>0 then logo_t=0 end
if butt<4 then
moveplayer(dirx[butt+1],diry[butt+1])
elseif butt==5 then
showinv()
sfx(54)
-- elseif butt==4 then
--win=true
--p_mob.hp=0
--st_killer="slime"
--genfloor(floor+1)
--prettywalls()
end
end
-->8
--draws
function draw_game()
cls(0)
if fadeperc==1 then return end
animap()
map()
for m in all(dmob) do
if sin(time()*8)>0 or m==p_mob then
drawmob(m)
end
m.dur-=1
if m.dur<=0 and m!=p_mob then
del(dmob,m)
end
end
for i=#mob,1,-1 do
drawmob(mob[i])
end
if _upd==update_throw then
--★
local tx,ty=throwtile()
local lx1,ly1=p_mob.x*8+3+thrdx*4,p_mob.y*8+3+thrdy*4
local lx2,ly2=mid(0,tx*8+3,127),mid(0,ty*8+3,127)
rectfill(lx1+thrdy,ly1+thrdx,lx2-thrdy,ly2-thrdx,0)
local thrani,mb=flr(t/7)%2==0,getmob(tx,ty)
if thrani then
fillp(0b1010010110100101)
else
fillp(0b0101101001011010)
end
line(lx1,ly1,lx2,ly2,7)
fillp()
oprint8("+",lx2-1,ly2-2,7,0)
if mb and thrani then
mb.flash=1
end
end
for x=0,15 do
for y=0,15 do
if fog[x][y]==1 then
rectfill2(x*8,y*8,8,8,0)
end
end
end
for f in all(float) do
oprint8(f.txt,f.x,f.y,f.c,0)
end
end
function drawlogo()
if logo_y>-24 then
logo_t-=1
if logo_t<=0 then
logo_y+=logo_t/20
end
palt(12,true)
palt(0,false)
spr(144,7,logo_y,14,3)
palt()
oprint8("the quest for kielbasa",19,logo_y+20,7,0)
end
end
function drawmob(m)
local col=10
if m.flash>0 then
m.flash-=1
col=7
end
drawspr(getframe(m.ani),m.x*8+m.ox,m.y*8+m.oy,col,m.flp)
end
--[[function draw_gover()
cls(2)
print("y ded",50,50,7)
end
function draw_win()
cls(2)
print("u win",50,50,7)
end]]--
function draw_gover()
cls()
palt(12,true)
spr(gover_spr,gover_x,30,gover_w,2)
if not win then
print("killed by a "..st_killer,28,43,6)
end
palt()
color(5)
cursor(40,56)
if not win then
print("floor: "..floor)
end
print("steps: "..st_steps)
print("kills: "..st_kills)
print("meals: "..st_meals)
print("press ❎",46,90,5+abs(sin(time()/3)*2))
end
function animap()
tani+=1
if (tani<15) return
tani=0
for x=0,15 do
for y=0,15 do
local tle=mget(x,y)
if tle==64 or tle==66 then
tle+=1
elseif tle==65 or tle==67 then
tle-=1
end
mset(x,y,tle)
end
end
end
-->8
--tools
function getframe(ani)
return ani[flr(t/15)%#ani+1]
end
function drawspr(_spr,_x,_y,_c,_flip)
palt(0,false)
pal(6,_c)
spr(_spr,_x,_y,1,1,_flip)
pal()
end
function rectfill2(_x,_y,_w,_h,_c)
--★
rectfill(_x,_y,_x+max(_w-1,0),_y+max(_h-1,0),_c)
end
function oprint8(_t,_x,_y,_c,_c2)
for i=1,8 do
print(_t,_x+dirx[i],_y+diry[i],_c2)
end
print(_t,_x,_y,_c)
end
function dist(fx,fy,tx,ty)
local dx,dy=fx-tx,fy-ty
return sqrt(dx*dx+dy*dy)
end
function dofade()
local p,kmax,col,k=flr(mid(0,fadeperc,1)*100)
for j=1,15 do
col = j
kmax=flr((p+j*1.46)/22)
for k=1,kmax do
col=dpal[col]
end
pal(j,col,1)
end
end
function checkfade()
if fadeperc>0 then
fadeperc=max(fadeperc-0.04,0)
dofade()
end
end
function wait(_wait)
repeat
_wait-=1
flip()
until _wait<0
end
function fadeout(spd,_wait)
if (spd==nil) spd=0.04
if (_wait==nil) _wait=0
repeat
fadeperc=min(fadeperc+spd,1)
dofade()
flip()
until fadeperc==1
wait(_wait)
end
function blankmap(_dflt)
local ret={}
if (_dflt==nil) _dflt=0
for x=0,15 do
ret[x]={}
for y=0,15 do
ret[x][y]=_dflt
end
end
return ret
end
function getrnd(arr)
return arr[1+flr(rnd(#arr))]
end
function copymap(x,y)
local tle
for _x=0,15 do
for _y=0,15 do
tle=mget(_x+x,_y+y)
mset(_x,_y,tle)
if tle==15 then
p_mob.x,p_mob.y=_x,_y
end
end
end
end
function explode(s)
local retval,lastpos={},1
for i=1,#s do
if sub(s,i,i)=="," then
add(retval,sub(s, lastpos, i-1))
i+=1
lastpos=i
end
end
add(retval,sub(s,lastpos,#s))
return retval
end
function explodeval(_arr)
return toval(explode(_arr))
end
function toval(_arr)
local _retarr={}
for _i in all(_arr) do
add(_retarr,flr(tonum(_i)))
end
return _retarr
end
function doshake()
local shakex,shakey=16-rnd(32),16-rnd(32)
camera(shakex*shake,shakey*shake)
shake*=0.95
if (shake<0.05) shake=0
end
-->8
--gameplay
function moveplayer(dx,dy)
local destx,desty=p_mob.x+dx,p_mob.y+dy
local tle=mget(destx,desty)
if iswalkable(destx,desty,"checkmobs") then
sfx(63)
mobwalk(p_mob,dx,dy)
st_steps+=1
p_t=0
_upd=update_pturn
else
--not walkable
mobbump(p_mob,dx,dy)
p_t=0
_upd=update_pturn
local mob=getmob(destx,desty)
if mob then
sfx(58)
hitmob(p_mob,mob)
else
if fget(tle,1) then
trig_bump(tle,destx,desty)
else
skipai=true
--mset(destx,desty,1)
end
end
end
unfog()
end
function trig_bump(tle,destx,desty)
if tle==7 or tle==8 then
--vase
sfx(59)
mset(destx,desty,76)
if rnd(3)<1 and floor>0 then
if rnd(5)<1 then
addmob(getrnd(mobpool),destx,desty)
sfx(60)
else
if freeinvslot()==0 then
showmsg("inventory full",120)
sfx(60)
else
sfx(61)
local itm=getrnd(fipool_com)
takeitem(itm)
showmsg(itm_name[itm].."!",60)
end
end
end
elseif tle==10 or tle==12 then
--chest
if freeinvslot()==0 then
showmsg("inventory full",120)
skipai=true
sfx(60)
else
local itm=getrnd(fipool_com)
if tle==12 then
itm=getitm_rar()
end
sfx(61)
mset(destx,desty,tle-1)
takeitem(itm)
showmsg(itm_name[itm].."!",60)
end
elseif tle==13 then
--door
sfx(62)
mset(destx,desty,1)
elseif tle==6 then
--stone tablet
if floor==0 then
sfx(54)
showtalk(explode(" welcome to porklike!,, climb this sausage, tower to obtain the, ultimate power of, the golden kielbasa, "))
end
elseif tle==110 then
--kielbasa
win=true
end
end
function trig_step()
local tle=mget(p_mob.x,p_mob.y)
if tle==14 then
sfx(55)
p_mob.bless=0
fadeout()
genfloor(floor+1)
floormsg()
return true
end
return false
end
function getmob(x,y)
for m in all(mob) do
if m.x==x and m.y==y then
return m
end
end
return false
end
function iswalkable(x,y,mode)
local mode = mode or "test"
--sight
if inbounds(x,y) then
local tle=mget(x,y)
if mode=="sight" then
return not fget(tle,2)
else
if not fget(tle,0) then
if mode=="checkmobs" then
return not getmob(x,y)
end
return true
end
end
end
return false
end
function inbounds(x,y)
return not (x<0 or y<0 or x>15 or y>15)
end
function hitmob(atkm,defm,rawdmg)
local dmg= atkm and atkm.atk or rawdmg
--add curse/bless
if defm.bless<0 then
dmg*=2
elseif defm.bless>0 then
dmg=flr(dmg/2)
end
defm.bless=0
local def=defm.defmin+flr(rnd(defm.defmax-defm.defmin+1))
dmg-=min(def,dmg)
--dmg=max(0,dmg)
defm.hp-=dmg
defm.flash=10
addfloat("-"..dmg,defm.x*8,defm.y*8,9)
shake=defm==p_mob and 0.08 or 0.04
if defm.hp<=0 then
if defm!=p_mob then
st_kills+=1
else
st_killer=atkm.name
end
add(dmob,defm)
del(mob,defm)
defm.dur=10
end
end
function healmob(mb,hp)
hp=min(mb.hpmax-mb.hp,hp)
mb.hp+=hp
mb.flash=10
addfloat("+"..hp,mb.x*8,mb.y*8,7)
sfx(51)
end
function stunmob(mb)
mb.stun=true
mb.flash=10
addfloat("stun",mb.x*8-3,mb.y*8,7)
sfx(51)
end
function blessmob(mb,val)
mb.bless=mid(-1,1,mb.bless+val)
mb.flash=10
local txt="bless"
if val<0 then txt="curse" end
addfloat(txt,mb.x*8-6,mb.y*8,7)
if mb.spec=="ghost" and val>0 then
add(dmob,mb)
del(mob,mb)
mb.dur=10
end
sfx(51)
end
function checkend()
if win then
music(24)
gover_spr,gover_x,gover_w=112,15,13
showgover()
return false
elseif p_mob.hp<=0 then
music(22)
gover_spr,gover_x,gover_w=80,28,9
showgover()
return false
end
return true
end
function showgover()
wind,_upd,_drw={},update_gover,draw_gover
fadeout(0.02)
end
function los(x1,y1,x2,y2)
local frst,sx,sy,dx,dy=true
--★
if dist(x1,y1,x2,y2)==1 then return true end
if y1>y2 then
x1,x2,y1,y2=x2,x1,y2,y1
end
sy,dy=1,y2-y1
if x1<x2 then
sx,dx=1,x2-x1
else
sx,dx=-1,x1-x2
end
local err,e2=dx-dy
while not(x1==x2 and y1==y2) do
if not frst and iswalkable(x1,y1,"sight")==false then return false end
e2,frst=err+err,false
if e2>-dy then
err-=dy
x1+=sx
end
if e2<dx then
err+=dx
y1+=sy
end
end
return true
end
function unfog()
local px,py=p_mob.x,p_mob.y
for x=0,15 do
for y=0,15 do
--★
if fog[x][y]==1 and dist(px,py,x,y)<=p_mob.los and los(px,py,x,y) then
unfogtile(x,y)
end
end
end
end
function unfogtile(x,y)
fog[x][y]=0
if iswalkable(x,y,"sight") then
for i=1,4 do
local tx,ty=x+dirx[i],y+diry[i]
if inbounds(tx,ty) and not iswalkable(tx,ty) then
fog[tx][ty]=0
end
end
end
end
function calcdist(tx,ty)
local cand,step,candnew={},0
distmap=blankmap(-1)
add(cand,{x=tx,y=ty})
distmap[tx][ty]=0
repeat
step+=1
candnew={}
for c in all(cand) do
for d=1,4 do
local dx=c.x+dirx[d]
local dy=c.y+diry[d]
if inbounds(dx,dy) and distmap[dx][dy]==-1 then
distmap[dx][dy]=step
if iswalkable(dx,dy) then
add(candnew,{x=dx,y=dy})
end
end
end
end
cand=candnew
until #cand==0
end
function updatestats()
local atk,dmin,dmax=1,0,0
if eqp[1] then
atk+=itm_stat1[eqp[1]]
end
if eqp[2] then
dmin+=itm_stat1[eqp[2]]
dmax+=itm_stat2[eqp[2]]
end
p_mob.atk=atk
p_mob.defmin=dmin
p_mob.defmax=dmax
end
function eat(itm,mb)
local effect=itm_stat1[itm]
if not itm_known[itm] then
showmsg(itm_name[itm]..itm_desc[itm],120)
itm_known[itm]=true
end
if mb==p_mob then st_meals+=1 end
if effect==1 then
--heal
healmob(mb,1)
elseif effect==2 then
--heal a lot
healmob(mb,3)
elseif effect==3 then
--plus maxhp
mb.hpmax+=1
healmob(mb,1)
elseif effect==4 then
--stun
stunmob(mb)
elseif effect==5 then
--curse
blessmob(mb,-1)
elseif effect==6 then
--bless
blessmob(mb,1)
end
end
function throw()
local itm,tx,ty=inv[thrslt],throwtile()
sfx(52)
if inbounds(tx,ty) then
local mb=getmob(tx,ty)
if mb then
if itm_type[itm]=="fud" then
eat(itm,mb)
else
hitmob(nil,mb,itm_stat1[itm])
sfx(58)
end
end
end
mobbump(p_mob,thrdx,thrdy)
inv[thrslt]=nil
p_t=0
_upd=update_pturn
end
function throwtile()
local tx,ty=p_mob.x,p_mob.y
repeat
tx+=thrdx
ty+=thrdy
until not iswalkable(tx,ty,"checkmobs")
return tx,ty
end
-->8
--ui
function addwind(_x,_y,_w,_h,_txt)
local w={x=_x,
y=_y,
w=_w,
h=_h,
txt=_txt}
add(wind,w)
return w
end
function drawind()
for w in all(wind) do
local wx,wy,ww,wh=w.x,w.y,w.w,w.h
rectfill2(wx,wy,ww,wh,0)
rect(wx+1,wy+1,wx+ww-2,wy+wh-2,6)
wx+=4
wy+=4
clip(wx,wy,ww-8,wh-8)
if w.cur then
wx+=6
end
for i=1,#w.txt do
local txt,c=w.txt[i],6
if w.col and w.col[i] then
c=w.col[i]
end
print(txt,wx,wy,c)
if i==w.cur then
spr(255,wx-5+sin(time()),wy)
end
wy+=6
end
clip()
if w.dur then
w.dur-=1
if w.dur<=0 then
local dif=w.h/4
w.y+=dif/2
w.h-=dif
if w.h<3 then
del(wind,w)
end
end
else
if w.butt then
oprint8("❎",wx+ww-15,wy-1+sin(time()),6,0)
end
end
end
end
function showmsg(txt,dur)
local wid=(#txt+2)*4+7
local w=addwind(63-wid/2,50,wid,13,{" "..txt})
w.dur=dur
end
function showtalk(txt)
talkwind=addwind(16,50,94,#txt*6+7,txt)
talkwind.butt=true
end
function addfloat(_txt,_x,_y,_c)
add(float,{txt=_txt,x=_x,y=_y,c=_c,ty=_y-10,t=0})
end
function dofloats()
for f in all(float) do
f.y+=(f.ty-f.y)/10
f.t+=1
if f.t>70 then
del(float,f)
end
end
end
function dohpwind()
hpwind.txt[1]="♥"..p_mob.hp.."/"..p_mob.hpmax
local hpy=5
if p_mob.y<8 then
hpy=110
end
hpwind.y+=(hpy-hpwind.y)/5
end
function showinv()
local txt,col,itm,eqt={},{}
_upd=update_inv
for i=1,2 do
itm=eqp[i]
if itm then
eqt=itm_name[itm]
add(col,6)
else
eqt= i==1 and "[weapon]" or "[armor]"
add(col,5)
end
add(txt,eqt)
end
add(txt,"……………………")