-
Notifications
You must be signed in to change notification settings - Fork 0
/
btd64.p8
2629 lines (2452 loc) · 82.2 KB
/
btd64.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 42
__lua__
--game data
cartdata("ingobeans_btd64_64")
function load_wlf(wlf)
lines = split(wlf,"\n")
local da = {}
for k,l in pairs(lines) do
if k != #lines then
local d = split(l,"|")
local w = {d[1]}
for i,c in pairs(d) do
if i != 1 then
local vs = split(c,",")
--if data has c at end,
--make camo
cbt = vs[2]
if type(cbt) == "string" then
cbt = tonum(sub(cbt,1,#cbt-1)+100)
end
for b=1,vs[1] do
add(w,cbt)
end
end
end
add(da,w)
end
end
return da
end
map_pts = {}
--gnd = nil --ground tile
wtr = 31 --water tile
lead_id = 9
save_g = 0
sell_percent = 0.8
function _init()
def_monkeys()
loads()
end
-->8
--game data raw
waves = load_wlf([[
25|20,1
15|30,1
15|20,1|5,2
15|30,1|15,2
15|5,1|25,2
15|15,1|15,2|4,3
15|20,1|25,2|5,3
15|10,1|20,2|14,3
15|30,3
15|102,2
15|10,1|10,2|12,3|2,4
15|15,2|10,3|5,4
15|100,1|23,3|4,4
15|49,1|15,2|10,3|9,4
15|20,1|12,3|5,4|3,5
15|20,3|7,4|4,5
15|7,4
15|70,3
15|10,3|4,4|5,4|6,5
15|6,6
15|14,5
15|7,7
15|5,6|4,7
15|1,3c
15|31,4
15|23,5|4,9
10|120,1|55,2|45,3|45,4
15|4,9
15|25,4|12,5
15|9,9
15|8,8|2,8
15|25,6|28,7|8,9
25|20,4c
15|140,4|5,8
15|35,5|25,7|5,10
15|81,5
15|20,6|20,7|7,7c|15,9|10,8
15|42,5|17,7|14,9|10,8|4,10
15|10,6|10,7|20,9|20,8|18,10
15|10,10|4,11
15|60,6|60,8
15|6,10c|6,10
15|10,10|7,11
15|50,8
10|200,5|8,9|25,10
15|1,12
15|70,5c|12,11
10|120,5|50,10
10|343,3|20,8|20,10|10,10|18,11
20|20,1|8,9|20,11|2,12
15|10,10|28,11
15|25,10|10,11|2,12
15|80,5c|3,12
15|35,11|2,12
15|45,11|1,12
15|40,10|1,12
15|40,10|4,12
15|29,11|5,12
17|28,9c|50,11
15|1,13
]])
bloon_types = load_wlf([[
0.5|1,192|1,1|1,1|1,6060
0.75|1,192|1,1|1,1|1,1|1,6060|1,8|1,12|1,14|1,13|1,2|1,1
0.9|1,192|1,1|1,1|1,2|1,6060|1,8|1,11|1,14|1,4|1,2|1,3
1.6|1,192|1,1|1,1|1,3|1,6060|1,8|1,10|1,14|1,7|1,2|1,9
0.9|1,192|1,1|1,1|1,4|1,6060|1,8|1,14|1,14|1,7
0.9|1,192|1,1|1,1|1,4|1,4|1,5|1,5|1,6060|1,8|1,0
1.0|1,192|1,1|1,1|1,4|1,4|1,5|1,5|1,6060|1,8|1,7|1,14|1,5|1,2|1,6
1.5|1,193|1,1|1,1|1,6|1,7|1,6060|1,5|1,0
0.9|1,194|1,1|1,1|1,6|1,6|1,6060
1.1|1,195|1,1|1,1|1,8|1,6060
1.25|1,196|1,1|1,10|1,10|1,10|1,6060
0.5|1,204|1,2|1,200|1,11|1,11|1,11|1,11|1,6060
0.17|1,236|1,2|1,700|1,12|1,12|1,12|1,12|1,6060
]])
maps = load_wlf([[
28|1,-1|1,6|1,3|1,6|1,3|1,4|1,6|1,4|1,6|1,10|1,1|1,10|1,1|1,14|1,11|1,14|1,11|1,6|1,16|1,6
48|1,-1|1,9|1,8|1,9|1,8|1,11|1,13|1,11|1,13|1,7|1,7|1,7|1,7|1,4|1,4|1,4|1,4|1,7|1,0|1,7|1,0|1,2|1,11|1,2|1,11|1,4|1,14|1,4|1,14|1,0
54|1,-1|1,14|1,6|1,14|1,6|1,11|1,5|1,11|1,5|1,9|1,8|1,9|1,8|1,12|1,11|1,12|1,11|1,6|1,9|1,6|1,9|1,9|1,15|1,9|1,15|1,4|1,6|1,4|1,6|1,5|1,4|1,5|1,4|1,0
191|1,4|1,0|1,4|1,10|1,9|1,10|1,9|1,5|1,8|1,5|1,4|1,5|1,4|1,10|1,9|1,10|1,9|1,5|1,8|1,5|1,4|1,5|1,4|1,15|1,4|1,15
]])
-->8
--game
playing = false
spawning = true
spwn_index = 2
spwn_timer = 0
ends = 0
--0 not ended
--1 loss screen
--2 win screen
fasts = false
in_main_menu = true
mm_map_i = 0
entered_menu = false
function set_game_vals()
lives = 100
cash = 650
round = 0
monkeys = {}
end
function start_round()
round += 1
playing = true
spawning = true
spwn_index = 2
spwn_timer = 0
end
function spwn_bloons()
if playing and spawning then
spwn_timer -= 1
if spwn_timer <= 0 then
spwn_timer = waves[round][1]
t = waves[round][spwn_index]
sx = map_pts[1]*8
sy = map_pts[2]*8
spwn_bloon({sx,sy},t)
spwn_index += 1
if spwn_index > #waves[round] then
spawning = false
end
end
elseif playing then
if #bloons == 0 then
cash += 100
playing = false
saves()
if round == 60 then
ends = 2
end
end
end
end
function main()
player_input()
menu_input()
mv_bloons()
update_monkeys()
update_proj()
empty_bloons_buffer()
spwn_bloons()
--perf_o(0,12)
end
function _draw()
if not in_main_menu then
if ends == 0 then
cls(0)
map(16*mm_map_i-16)
draw_bloons()
draw_proj()
draw_particles()
draw_monkeys()
draw_cursor()
draw_ui()
draw_tooltip()
else
if ends == 1 then
cls(0)
color(8)
print("you lost at round "..round,26,12)
else
cls(7)
color(11)
print("you won!",48,12)
end
print("press ❎ to return",30,118)
end
end
end
function _update()
if not in_main_menu then
if ends == 0 then
main()
else
if btnp(❎) then
dset()--implicit 0,0
run()
end
end
else
main_menu()
end
end
function main_menu()
mx = #maps
palt(0,false)
map(0,16)
--border
rectfill(10,18,117,117,0)
palt()
pal()
mn = 1
--draw map preview
tbc = 0
tc = 8
t = "will overwrite your save!"
mdi = mm_map_i
if mm_map_i == 0 then
tbc = 7
tc = 11
t = "load saved game?"
mdi = save_g
end
clip(11,19,106,98)
map(mdi*16-16)
if mm_map_i == 0 then
draw_monkeys()
end
if save_g != 0 then
rectfill(11,19,117,29,tbc)
print(t,15,20,tc)
mn = 0
end
-- draw play button
rectborder(52, 101, 76, 111, 12, 0)
print("play", 56, 104, 0)
--input
if btnp(⬅️) then
mm_map_i -= 1
if mm_map_i < mn then
mm_map_i = mx
end
end
if btnp(➡️) then
mm_map_i += 1
if mm_map_i > mx then
mm_map_i = mn
end
end
if btnp(❎) then
in_main_menu = false
if mm_map_i == 0 then
mm_map_i = save_g
else
set_game_vals()
end
m = maps[mm_map_i]
gnd = m[1]
del(m,gnd)
map_pts = m
end
end
-->8
--bloons
bloons = {}
bloons_buffer = {}
function empty_bloons_buffer()
for k,v in pairs(bloons_buffer) do
spwn_bloon(v[1],v[2],v[3],v[4],v[5],v[6],v[7])
end
bloons_buffer = {}
end
--[[
function calc_bloon_val(bt)
local bd = bloon_types[bt]
local v = bd[4]
if #bd[4] == 0 then
return 1
end
v += calc_bloon_val(bd[4][1])
return v
end
--]]
function get_next_layer(bt,pp)
local v = pp-1
local cl = (bt>100) and bt-100 or bt
while true do
local bd = btype(cl)
v -= bd[4]
if v < 0 then
break
end
if bd[5] == 6060 then
break
end
cl = bd[5]
end
local t = {}
local i = 5
local adr = (bt>100) and 100 or 0
while true do
local pv = bloon_types[cl][i]
if pv == 6060 then
break
end
add(t,pv+adr)
i+=1
end
return t
end
function confuse_bloon(b,amt)
amt = min(b.pt-1,amt)
if b.pt > 0 and amt > 0 then
b.cnf = b.pt
for i=1,amt do
b.s -= b.ptss[b.pt-i+1]
end
b.pt -= amt
end
end
function pop_bloon(bi,pp,pmom,plead)
b = bloons[bi]
if not b then
return
end
bt = btype(b.t)
if b.t == lead_id and plead != true then
return
end
if bt[6] != 1 then
if b.h > 1 then
m = 1
if bt[7] == true then
m = pmom
end
b.h -= pp*m
if b.h > 1 then
return
end
end
end
for k,v in pairs(get_next_layer(b.t,pp)) do
p = {b.p[1], b.p[2]}
add(bloons_buffer,{
p,v,bi,b.pt,b.s,b.ptss,b.cnf
})
end
cash += 1
sfx(rnd(5))
del(bloons,b)
end
function bloons_at(pos)
b = {}
x = pos[1]
y = pos[2]
for k,v in pairs(bloons) do
cx = v.p[1]
cy = v.p[2]
if x > cx and x < cx+8 and
y > cy and y < cy+8 then
add(b,{v,k})
end
end
return b
end
function btype(t)
if t > 100 then
return bloon_types[t-100]
end
return bloon_types[t]
end
function spwn_bloon(pos,t,id,pt,s,ptss,cnf)
id = id or #bloons + 1
pt = pt or 1
ptss = ptss or {0}
cnf = cnf or false
s = s or 0
add(bloons, {
p=pos, --pos
t=t, --type
pt=pt, --point target
s=s, --score
ptss=ptss, --point scores
cnf=cnf, --confused
h=btype(t)[4], --health
lmd={0,0}
})
end
function draw_bloons()
for k,v in pairs(bloons) do
bt = btype(v.t)
img = bt[2]
if v.t > 100 then
img += 16
end
bs = bt[3]
bmxh = bt[4]
if bmxh != 1 then
if v.h < bmxh / 2 then
img += bs
end
end
is = indexof(bt,6060)
if is then
for k=is+1,#bt,2 do
pal(bt[k], bt[k+1])
end
end
--if moab, calculate angle
--of move, and draw rotated
if bs > 1 then
--print(v.h,v.p[1]+12,v.p[2],0)
--normalise move dir
md = sqrt(abs(v.lmd[1])^2+abs(v.lmd[2])^2)
mnx = v.lmd[1]/md
mny = v.lmd[2]/md
a = atan2(mny,mnx)+0.25
spr_r(img, v.p[1]-4, v.p[2]-4, a, bs, bs)
else
spr(img, v.p[1], v.p[2], bs, bs)
end
--if h == nil or v.s > h[1] then
-- h = {v.s,{v.p[1],v.p[2]}}
--end
pal()
end
--if h != nil then
-- spr(64, h[2][1], h[2][2])
-- print(h[1],h[2][1], h[2][2])
--end
end
function mv_bloons()
for k,v in pairs(bloons) do
mv = {0,0}
spd = btype(v.t)[1]
next_pt = {
map_pts[v.pt*2-1],
map_pts[v.pt*2]
}
--print(v.p[1],22,22,8)
--print(map_pts[v.pt*2],22,32,8)
--print(#map_pts,22,42,8)
--print(v.pt,22,52,8)
dix = v.p[1]-next_pt[1]*8
diy = v.p[2]-next_pt[2]*8
ma = 0
if dix < 0 then
mv[1] = min(spd,-dix)
elseif dix > 0 then
mv[1] = -min(spd,dix)
end
if diy < 0 then
mv[2] = min(spd,-diy)
elseif diy > 0 then
mv[2] = -min(spd,diy)
end
nx = v.p[1] + mv[1]
ny = v.p[2] + mv[2]
ma = abs(mv[1]) + abs(mv[2])
--give no score if confused
if v.cnf == false then
v.s += ma
v.ptss[v.pt] += ma
end
v.p = {nx, ny}
v.lmd = mv
if nx/8 == next_pt[1] and
ny/8 == next_pt[2] do
v.pt += 1
v.ptss[v.pt] = 0
if v.cnf == v.pt then
v.cnf = false
end
if v.pt > #map_pts/2 then
lives -= 1
if lives <= 0 then
ends = 1
end
del(bloons,v)
end
end
end
end
-->8
--player
crsr = {8,8}
function monkey_at(pos)
for k,v in pairs(monkeys) do
if pos[1] == v.p[1]-4 and
pos[2] == v.p[2]-4 then
return v,k
end
end
return false,false
end
function player_input()
if in_menu == -1 then
mv_crsr()
if btnp(🅾️) then
if placing != -1 then
placing = -1
else
menu_crsr = 0
in_menu = 0
entered_menu = true
end
elseif btnp(❎) and placing == -1 then
crp = {crsr[1]*8,crsr[2]*8}
m,i = monkey_at(crp)
if m then
menu_crsr = 0
in_menu = i
entered_menu = true
end
elseif btnp(❎) and valid then
mt = monkey_types[placing]
cash -= mt.c
spwn_monkey({crsr[1]*8+4,crsr[2]*8+4},placing)
placing = -1
sfx(12)
end
else
if btnp(🅾️) then
in_menu = -1
end
end
end
function mv_crsr()
if btnp(⬅️) do
crsr[1] -= 1
elseif btnp(➡️) do
crsr[1] += 1
end
if btnp(⬆️) do
crsr[2] -= 1
elseif btnp(⬇️) do
crsr[2] += 1
end
if crsr[1] < 0 do
crsr[1] = 15
elseif crsr[1] > 15 do
crsr[1] = 0
end
if crsr[2] < 1 do
crsr[2] = 14
elseif crsr[2] > 14 do
crsr[2] = 1
end
end
-->8
--ui
-- -1 none
-- 0 build
-- <monkey id> upgrade
in_menu = -1
menu_crsr = 0
-- -1 none
-- <monkey id> placing
placing = -1
valid = true
--in upgrade menu
extra_info = false
function rectborder(x1,y1,x2,y2,clr1,clr2)
rectfill(x1,y1,x2,y2,clr1)
rect(x1,y1,x2,y2,clr2)
end
function draw_tooltip()
rectfill(0,120,127,127,0)
o = "menu"
x = false
l = false
r = false
if in_menu != -1 then
o = "exit"
x = "select"
if in_menu != 0 then
if extra_info then
r = "show less"
else
l = "show more"
end
end
elseif placing != -1 then
o = "exit"
x = "confirm"
else
if monkey_at({crsr[1]*8,crsr[2]*8}) then
x = "select"
end
end
print("🅾️ "..o,0,121,7)
if x then
print("❎ "..x,32,121,7)
end
if l then
print("⬅️ "..l,72,121,7)
end
if r then
print("➡️ "..r,72,121,7)
end
end
function mv_menu_crsr()
if btnp(⬆️) then
menu_crsr -= 1
elseif btnp(⬇️) then
menu_crsr += 1
end
mx = 3
if in_menu == 0 then
mx = 9--#monkey_types+1 - change if add new monkey
end
if menu_crsr < 0 then
menu_crsr = mx
elseif menu_crsr > mx then
menu_crsr = 0
end
end
function menu_input()
if in_menu == -1 or entered_menu then
entered_menu = false
return
end
mv_menu_crsr()
if in_menu == 0 then
if btnp(❎) then
if menu_crsr == 0 then
if not playing then
start_round()
end
elseif menu_crsr == 1 then
fasts = not fasts
if fasts then
_set_fps(60)
_update60 = _update
else
_set_fps(30)
_update60 = nil
end
else
mt = monkey_types[menu_crsr-1]
if cash >= mt.c then
in_menu = -1
placing = menu_crsr-1
end
end
end
else
m = monkeys[in_menu]
if btnp(❎) then
if menu_crsr == 3 then
cash += flr(m.vl*sell_percent+0.5)
in_menu = -1
sfx(11)
del(monkeys,m)
elseif menu_crsr == 0 then
m.tg += 1
if m.tg > 3 then
m.tg = 0
end
else
u = nil
if menu_crsr == 1 then
if m.ui2 < 4 or m.ui1 != 3 then
u = m.u1[m.ui1]
end
else
if m.ui1 < 4 or m.ui2 != 3 then
u = m.u2[m.ui2]
end
end
if u then
if cash >= u[1] then
if menu_crsr == 1 then
m.ui1 += 1
else
m.ui2 += 1
end
cash -= u[1]
sfx(12)
m.vl += u[1]
u[4](m)
end
end
end
elseif btnp(⬅️) then
extra_info = true
elseif btnp(➡️) then
extra_info = false
end
end
end
function draw_menu()
rectborder(80,0,127,127,4,15)
if in_menu == 0 then
if not playing then
rectfill(81,1,126,10,12)
print("start round",82,2,15)
else
rectfill(81,1,126,10,1)
print("start round",82,2,5)
end
rectborder(80,10,127,20,12,15)
print("speed "..(fasts and "2" or "1").."x",83,12,15)
--draw monkey buttons
for k,v in pairs(monkey_types) do
rectfill(80,k*10+10,89,20+k*10,0)
rect(80,k*10+10,127,20+k*10,15)
draw_base_monkey(k,{81,k*10+11})
print("$"..v.c,92,k*10+12,15)
end
spr(64,72,menu_crsr*10)
else
m = monkeys[in_menu]
rectfill(81,1,126,9,0)
print("upgrade",93,2,7)
draw_base_monkey(m.ti,{81,1})
--draw upgrade buttons
buttons = {m.u1[m.ui1],m.u2[m.ui2]}
--lock upgrade paths
--by setting button to 0
if m.ui1 >= 4 and m.ui2 == 3 then
buttons[2] = 0
elseif m.ui2 >= 4 and m.ui1 == 3 then
buttons[1] = 0
end
--nil gets skipped in
--pair loops so we flag
--nil values by 1
if not buttons[1] then
buttons[1] = 1
end
if not buttons[2] then
buttons[2] = 1
end
for ki,v in pairs(buttons) do
local k = ki+1
if v == 0 then
rect(80,k*10,127,10+k*10,15)
spr(80,85,k*10+2)
print("locked",95,k*10+2,15)
if extra_info then
rectborder(0,k*10,80,k*10+10,4,15)
print("path is locked",0+2,k*10+2,15)
end
elseif v == 1 then
rect(80,k*10,127,10+k*10,15)
print("max upg.",85,k*10+2,15)
if extra_info then
rectborder(0,k*10,80,k*10+10,4,15)
print("all upgrades",0+2,k*10+2,15)
end
else
rectfill(83,k*10,92,10+k*10,0)
rect(80,k*10,127,10+k*10,15)
spr(v[2],85,k*10+2)
print("$"..v[1],95,k*10+2,15)
if extra_info then
rectborder(0,k*10,80,k*10+10,4,15)
print(v[3],0+2,k*10+2,15)
end
end
end
--draw upgrade progress
for ki,v in pairs({m.ui1,m.ui2}) do
local k = ki+1
for i=1,3 do
c = 3
--if upgrade is bought
if 4-i<v then
c = 11
end
rectfill(81,k*10+i*3-3+1,83,k*10+i*3,c)
end
end
--targeting button
rectborder(80,10,127,20,4,15)
ts = {
"first",
"strong",
"near",
"last"
}
print(ts[m.tg+1],83,12,15)
--sell button
rectborder(80,40,127,50,8,15)
print("sell $"..flr(m.vl*sell_percent+0.5),83,42,15)
spr(64,72,menu_crsr*10+10)
end
if entered_menu == false then
--menu_input()
else
entered_menu = false
end
end
function draw_cursor()
clr = 7
if placing != -1 then
valid = true
if not monkey_types[placing].wb then
local t = mget(crsr[1]+mm_map_i*16-16,crsr[2])
if t != gnd and t != gnd-16 then
valid = false
end
else
if mget(crsr[1]+mm_map_i*16-16,crsr[2]) != wtr then
valid = false
end
end
if valid then
for k,v in pairs(monkeys) do
if v.p[1]-4 == crsr[1]*8 and
v.p[2]-4 == crsr[2]*8 then
valid = false
end
end
end
if not valid then
clr = 8
end
mt = monkey_types[placing]
draw_base_monkey(placing,{crsr[1]*8,crsr[2]*8})
circ(crsr[1]*8+4,crsr[2]*8+4,mt.r*8,0)
end
rect(crsr[1]*8-1, crsr[2]*8-1, crsr[1]*8+8, crsr[2]*8+8, clr)
end
function draw_ui()
draw_topbar()
if in_menu != -1 then
draw_menu()
end
end
function draw_topbar()
rectfill(0,0,128,8,0)
round_clr = 7
if playing then
round_clr = 8
end
print("round "..round,0,0,round_clr)
print("$"..cash,52,0,10)
print("♥"..lives,108,0,8)
end
-->8
--monkeys data
monkey_types = {}
function new_mk(t)
base = {
p={0,0}, --pos
cs={{}}, --color states
ccs=1, --current color state
vl=0, --value
c=200,--cost
wb=false, --water bound
camo=false, --camo
i=1, --sprite
trac=14, --transparency colour
r=2.5, --range
proji=1, --current proj index
projs={base_proj},
adc=0, --attack delay counter
tg=0, --target (0 first, 1 strong, 2 near, 3 last)
lar={0,-1}, --last attack dir
u1={}, --upgrade path 1
u2={}, --upgrade path 2
ui1=1, --upgrade index 1
ui2=1 --upgrade index 2
}
b = merge(base,t)
b.vl = b.c
b.ti = #monkey_types+1
add(monkey_types, b)
return b
end
function merge(b,n)
local m = deep(b)
for k,v in pairs(n) do
if b[k] != nil then
if type(v) == "table" then
m[k] = merge(b[k],n[k])
else
m[k] = n[k]
end
else
m[k] = v
end
end
return m
end
function def_monkeys()
base_proj = {
a = reg_attack, --atack func
amt=1, --times to loop proj