-
Notifications
You must be signed in to change notification settings - Fork 1
/
birds_with_guns_final_2.p8
2864 lines (2410 loc) · 91.4 KB
/
birds_with_guns_final_2.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 33
__lua__
-- -- birds with guns --
--by yolwoocle & gouspourd
--extra credits :notgoyome
--music: simon t.
--final update !
--bird ideas
--crow,owl,raven,pelican,goose,
--colibri,dinosaur,cockatiel
--peafowl
degaplus = 0
function _init()
keyboard = false
initguns()
enemies,checker = {},{}
--mouse
mx,my=0,0
--flags
solid,breakable,spawnable,lootable,notbulletsolid=0,1,2,3,4
--camera
shake,camy,camx,targetcamx=0,0,0,0
cam_follow_player=true
trainpal = {{8,2},{11,3},
{7,13},{12,13},{10,9},{0,2}}
pal_n,menu = 1,"main"
actors = {}
init_enemies()
init_player(111)
init_ptc()
wl,diffi = 4,20
--wagon length
wagon_n,trainlen = 0,6
tl = trainlen
gen_train()
update_room()
random,enemies = {},{}
parcourmap()
drops={}
init_menus()
birdchoice,hardmodetimer=0,0
ofsetboss,bullets_shooted,bullets_hit = 0,1,1
stats={
time=0,
kills=0,
wagon=0,
}
is_boss = false
boss_pos = {0,0}
win,wintimer = false,0
--darker blue
--pal(1,130,1)
--pal(1,129,1)
pal()
poke(0x5f2e,1)
local s = stat(6)
if s == "-"
or s == ""
or s == nil then
menu="main"
else
menu="game"
birdchoice=tonum(stat(6))
begin_game()
end
end
function _update60()
mouse_x_y()
for i=0x3100,0x3148 do
--on
poke(i,peek(i)&0b10111111)
end
if hardmodetimer > 90 and
menu == "main" and diffi != 17 then
sfx(44)
shake,diffi = 5,17
degaplus = 1
initguns()
init_enemies()
end
grasstile()
if(win) wintimer += 1
if wintimer == 180 then
menu="win"
set_stats()
end
--if(wintimer==180)sfx(46)
if menu == "game" then
delchecker()
update_drops()
player_update()
for a in all(actors) do
--actors are just bullets
a:update()
if a.destroy_flag then
if a.dmg == 0 then
animexplo(a)
guns.explosion:fire(a.x-a.dx*2,a.y-a.dy*2,1)
elseif a.dmg == 0.1 then
--firework launcher
for i=1,10 do
sfx(32)
guns.machinegun:shoot(a.x-a.dx*2,a.y-a.dy*2,i/10)
end
end
del(actors,a)
end
end
--for e in all(enemies) do
update_enemy(e)
--if(e.destroy_flag)del(enemy,e)
--end
for ptc in all(particles) do
update_ptc(ptc)
if(ptc.destroy)del(particles,ptc)
end
update_door()
--shake = 0
update_camera()
elseif menus[menu] then
local m = menus[menu]
m.update(m)
sprms = 127
end
shake = max(0,shake-0.3)
local txt=keyboard and "keyboard" or "mouse+keys"
menuitem(3,"mode:"..txt, function() keyboard = not keyboard end)
menuitem(2,"⌂ main menu", function() run("-") end)
if (btn(❎) or btn(🅾️)) keyboard = true
if (lmb) keyboard = false
end
function _draw()
local ox = rrnd(shake)
local oy = rrnd(shake)
--if (keyboard == true)
camera(camx+ox, camy+oy)
cls(15)
--draw map
drawgrass()
draw_map()
if wagon_n==0 and menu=="game" then
local s= [[
⬆️ [e]
⬅️⬇️➡️ or [s d f]
move
[click] shoot
[scroll] change
weapon
]]
if(keyboard)s=[[
⬆️
⬅️⬇️➡️ move
❎ (x) shoot
🅾️ (c) change
weapon
]]
print(s,33,42,2)
end
draw_weel()
draw_drops()
for e in all(enemies) do
draw_enemy(e)
end
draw_player()
for a in all(actors) do
a:draw()
end
for ptc in all(particles) do
draw_ptc(ptc)
end
if(menu!="main")draw_player_ui(p)
local m = menus[menu]
if m then
m.draw(m)
end
-->>no code below this<<--
--draw mouse
if(not keyboard or menu=="game")spr(sprms,mx-1,my-1)
pal(1,129,1)
end
----------
function set_stats()
stats.time=flr(
(time()-stats.time) * 10) / 10
local t = stats.time
local s = ""
if(t%60 < 10) s="0"
stats.time= tostr(t\60)..":"..s..tostr(t%60)
--stats.time=(flr(stats.time)\60)+((flr(stats.time)-(flr(stats.time)\60)*60)/100)
stats.wagon=tostr(wagon_n+1).."/7"
end
function begin_game()
sfx(37)
music()
local b=birdchoice or 0
if b == 0 then
b=flr(rnd(12))+1
end
init_player(111+b)
stats.time = time()
p.x,p.y = 48,56
shake += 7
for i=1,10 do
make_ptc(
48 + rrnd(8),
56 + rrnd(8),
8+rnd(8),rnd({2,4,6}),0.97,
rrnd(2),rrnd(2)
)
end
end
function isleft(a)
return a<.75 and .25<a
end
function ospr(s,x,y,col)
for i=0,15 do
pal(i,col)
end
for i=-1,1do
for j=-1,1do
spr(s,x+i,y+j)
end
end
pal()
spr(s,x,y)
end
function oprint(t,x,y,col,ocol)
local ocol = ocol or 1
for i=-1,1do
for j=-1,1do
print(t,x+i,y+j,ocol)
end
end
local col = col or 7
print(t,x,y,col)
end
function copy(t)
local n={}
for k,v in pairs(t) do
n[k] = v
end
return n
end
function update_camera()
local px = p.x
local wl = wl
local maxlen = 240
--poke(0x5f40,0)
poke(0x5f43,0)
if px > 128*(wl-1)+8 then
--pan cam to connector room
cam_follow_player=false
targetcamx=128*(wl-1)
--block off old entrance
if wagon_n != tl-1 then
--mset(48,7,6)
--mset(48,6,13)
end
--low-pass filter & slow
--poke(0x5f40,15)
if(wagon_n!=tl)poke(0x5f43,15)
end
if cam_follow_player then
--camera follows player
camx = px-60
--offset camera to cursor
if not keyboard then
camx += (stat(32)-64)/3
end
camx = mid(0, camx, 128*(wl-2)+8) \ 1
camy = 0
else
--do a cool animation
camx=ceil(
camx+(targetcamx-camx)/10)
if targetcamx <= 0
and ceil(camx)==targetcamx then
cam_follow_player=true
end
end
end
function draw_ghost_connector()
if camx<0 then
map(0,16, -128,0, 16,16)
end
end
function rrnd(n)
--"radius rnd"
return rnd(2*n)-n
end
function allbtn(b)
return btn(b) or btn(b,1)
end
--[[
function debug_()
local p =players[1]
p.gunls[1] = debuggun
wagon_n = tl-1
for i in all(enemies)do
i.destory = true
end
p.maxlife = 10000
p.life = 10000
end--]]
-->8
--player
function init_player(bird)
b=0
dx1=1
dy1=0
p = {
n=1,
agro = 9999,
x=-64,y=-64,
dx=0,dy=0,
a=0,
spd=.4,
fric=0.75,
bx=2,by=2,
bw=4,bh=4,
hx=2,hy=2,
hw=4,
life=10,
maxlife=10,
ammo=250,
maxammo=250,
spr=bird,
gun=nil,
gunn=1,
gunls={},
lmbp = true,
iframes=30,
damage=damage_player,
spriteoffset = 0,
kak = copy(kak)
}
p.gun = p.gunls[1]
--should we keep this in? bird stats
-- [[
local n = bird-111
--[[local bird_stats=split(
[[n, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
,life, 10, 10, 5, 10, 10, 10, 10, 10, 10, 2, 10, 10
,maxlife,10, 10, 5, 10, 10, 10, 10, 10, 10, 15, 10, 10
,spd, .4, .4, .4, .4, .4, .4, .4, .4, .55, .4, .4, .4
,fric, .75,.75,.75,.75,.75,.75,.75,.75,.75,.74,.75,.75
]])
for i=1,#bird_stats,13 do
p[bird_stats[i] ] = bird_stats[i+n]
end
--]]
-- [ default ][ pigeon ][ duck ][ sparrow ][ parrot ][ toucan ][ flamingo ][ eagle ][ seagull ][ ostrich ][ penguin ][ jay ][ chicken ]
local bird_weapons=split("revolver,shotgun,revolver,shotgun,revolver,flamethrower,boxing_glove,fireworklauncher,machinegun,fireworklauncher,boxing_glove,shotgun,revolver,ringcannon,boxing_glove,assaultrifle,machinegun,sniper,machinegun,gatlinggun,shotgun,sniper,shotgun,assaultrifle,revolver,bazooka")
for i=1,2 do
p.gunls[i] = copy(guns[bird_weapons[2*n+i] ])
end
update_gun(p)
end
function player_update()
--damage
p.iframes = max(0,p.iframes-1)
--movement
local dx,dy = p.dx,p.dy
local spd = p.spd
if (allbtn(⬅️)) p.dx-=spd dx1-=spd
if (allbtn(➡️)) p.dx+=spd dx1+=spd
if (allbtn(⬆️)) p.dy-=spd dy1-=spd
if (allbtn(⬇️)) p.dy+=spd dy1+=spd
--58
p.dx *= p.fric
p.dy *= p.fric
if (abs(dx1)+abs(dy1))>0.1 then
dx1 *= p.fric
dy1 *= p.fric
end
collide(p,0.1)
p.x += p.dx
p.y += p.dy
--animation
if abs(p.dx)+abs(p.dy)>0.75 then
animplayer(p)
else
p.spriteoffset = 0
end
--aiming
if keyboard then
sprms=76
distmin=9999
indexmininit={x=p.x-ofsetboss+dx1,y=p.y-ofsetboss+dy1}
indexmin=indexmininit
for e in all(enemies) do
if loaded(e) and
canshoot(p,e) then
local dist = dist(p,e)
if (distmin>dist) distmin=dist indexmin=e
end
end
ofsetboss = 0
if(indexmin.spr == 1) ofsetboss = 4
p.a = atan2(indexmin.x+ofsetboss-p.x,
indexmin.y+ofsetboss-p.y)
mx=indexmin.x+1+ofsetboss
my=indexmin.y+1+ofsetboss
if(indexmin==indexmininit)sprms=57
else
sprms = 127
p.a = atan2(mx-p.x,
my-p.y)
end
p.flip = isleft(p.a)
--ammo & life
p.life=min(max(0,p.life),p.maxlife)
p.gun.ammo=min(max(0,p.gun.ammo),p.gun.maxammo)
--death
if p.life <= 0
and menu!="death"then
sfx(34)
music(-1, 300)
menu = "death"
shake += 9
burst_ptc(p.x+4,p.y+4,7)
set_stats()
end
--shooting
if stat(36) ==1 or stat(36) ==-1 or (btnp(🅾️)) then
nextgun(p)
--print(p.gun.cooldown,0,0)
p.gun.timer = p.gun.cooldown/2
end
local fire=lmb or btn(❎)
local active=rmb
local dofire
p.kak:update()
p.gun:update()
test = p.gun.name
-- not auto
if fire and
p.gun.timer<=0 and
p.gun.ammo > 0 and p.gun.auto == false
then
if p.lmbp == true then
dofire = true
p.lmbp = false
end
-- auto
elseif fire and p.gun.timer<=0
and p.gun.ammo > 0 then
dofire = true
elseif fire and
p.gun.ammo < 1 and
p.lmbp == true and
p.kak.timer<=0 then
coupdekak(p)
p.lmbp = false
end
if dofire then
make_ptc(p.x+cos(p.a)*6+4,
p.y+sin(p.a)*3+4, rnd(3)+6,7,.7)
p.gun.ammo -= 1
p.gun:fire(p.x+4,p.y+4,p.a)
end
-- if mleft not pressed
if not fire then
p.lmbp = true
end
--begin boss
local w3=128*(wl-1)
if wagon_n==tl and p.x>w3
and cam_follow_player
and not is_boss then
is_boss = true
begin_boss()
p.x = w3+8
end
--next wagon
if p.x>128*wl then
random = {}
wagon_n += 1
update_room()
enemiescleared=false
pal_n += 1
--pan cam to next wagon
camx = -128
targetcamx=0
drops = {}
enemies = {}
parcourmap()
--teleport players
p.x -= 128*wl
p.x = max(p.x, 0)
end
for e in all(enemies)do
if touches_rect(
p.x+4,p.y+4,
e.x+1,e.y+1,e.x+7,e.y+7) then
if (p.iframes == 0) then
sfx(35)
if(shake<=2)shake += 2
if e.spr != 126 then
p.life-=1+(degaplus*2)
else
p.life-=1+degaplus
end
p.iframes = 30
if e.spr == 109 then
p.life+=1
killbarelle(e)
p.iframes = 0
end
end
knockback_player(p,e)
end
end
end
function draw_player()
if (p.iframes%5) == 0 then
local x=flr(p.x) + cos(p.a)*6 +0
local y=flr(p.y) + sin(p.a)*3 +0
if p.gun.name=="sniper" then
local c,s=cos(p.a),sin(p.a)
line(
x+4+c*6,
y+4+s*6,
p.x+c*128,
p.y+s*128,8)
end
spr(p.gun.spr,x,y,1,1, p.flip)
palt(0,false)
palt(1,true)
spr(p.spr,p.x,p.y+p.spriteoffset,1,1, p.flip)
palt()
end
end
function draw_player_ui(p)
--life counter
rectfill(camx+1,1,camx+43,7,2)
local l=40*(p.life/p.maxlife)
rectfill(camx+2,2,camx+2+l,6,8)
local s="♥"..p.life.."/"..p.maxlife.." "
print(s, camx+2,2,7)
--ammo bar
rectfill(camx+84,1,camx+84+42,7,4)
local l=40*(p.gun.ammo/p.gun.maxammo)
if(p.ammo>0)rectfill(camx+85,2,camx+85+l,6,9)
local s,col = tostr(p.gun.ammo),7
if(s=="0") s,col="no ammo!",14
spr(110,camx+89,2)
print(s, camx+95,2,col)
--weapon list
for i=1,2 do
local col = 1
if(i==p.gunn)col=7
ospr(p.gunls[i].spr,
camx+90+(i-1)*10, 10,col)
end
--wagon
local color = 7
if degaplus == 1 then
color = 8
else color = 7
end
oprint("wagon "..wagon_n+1 .."/7",
camx+46,2,color,1)
--print(test,0,80)
end
function nextgun(p)
sfx(36)
p.gunn += 1
if(p.gunn > #p.gunls) p.gunn = 1
update_gun(p)
--[[local f = 0
for i=1,#p.gunls do
if p.gunls[i] == p.gunn then
if (((i+stat(36))%#p.gunls)<1) f = #p.gunls
return p.gunls[(i+stat(36))%(#p.gunls)+f]
end
end]]
end
function update_gun(p)
p.gun = p.gunls[p.gunn]
end
function knockback_player(p,e)
if abs(p.dx)+abs(p.dy) < 3 then
p.dx+=e.dx*e.spd*2
p.dy+=e.dy*e.spd*2
end
end
function knockback_enemy(e,b)
if (abs(e.dx)+abs(e.dy<30)) then
e.dx+=b.dx*b.spd*.1
e.dy+=b.dy*b.spd*.1
end
end
function animplayer(p)
if flr(time()*7)%2==1 then
p.spriteoffset = 1
else
p.spriteoffset = 0
end
end
function coupdekak(p)
local x=flr(p.x) + cos(p.a)*6 +0
local y=flr(p.y) + sin(p.a)*3 +0
p.kak:fire(x+4,y+4,p.a)
end
-->8
--gun & bullet
function make_gun(args,fire)
local name_,sprr,cd_,spd,oa,dmg,is_enemy,auto,maxammo,sfxx,knockback=unpack(split(args))
is_enemy = is_enemy == 1
auto = auto == 1
if(is_enemy) dmg += degaplus * 2
--todo:not have 3000 args
local gun = {
name=name_,
spr=sprr,
spd=spd,
oa=oa,--offset angle in [0,1[
dmg=dmg,
shake=shake,
auto=auto,
ammo=maxammo,
maxammo=maxammo,
timer=0,
cooldown=cd_,
is_enemy=is_enemy,
x=0,y=0,
dir=0,
burst=0,
sfx=sfxx,
knockback=knockback,
}
gun.fire = fire
gun.shoot=function(gun,x,y,dir,spd,knockback)
--remove? it complicates code
if(gun.burst<=0)dir+=rrnd(gun.oa)
if(gun.sfx) sfx(gun.sfx)
local s=93
local name = gun.name
local palette = ""
if(gun.is_enemy)s=95
if(name=="kak")s=77 lifspa=5
if(name=="boxing glove")s,lifspa=77,10
if(name=="flamethrower") lifspa=40 palette="1,2,3,4,5,6,10,8,8,9"
if(name=="explosion")s=57 lifspa=10
if(name=="bazooka") palette="1,2,3,4,5,6,6,8,5,13"
if not gun.is_enemy then
if(shake<1 and name!="flamethrower")shake+=1
end
spd = spd or gun.spd
spawn_bullet(x,y,dir,
spd,3,s,dmg,is_enemy,lifspa,palette)
lifspa=nil
gun.timer = gun.cooldown
p.dx-=cos(dir)*gun.knockback
p.dy-=sin(dir)*gun.knockback
end
gun.update=function(gun)
gun.timer = max(gun.timer-1,0)
gun.ammo = mid(0,gun.ammo,gun.maxammo)
if gun.burst > 0 then
gun:shoot(gun.x,gun.y,gun.dir)
gun.burst -= 1
end
end
return gun
end
function shoot1(gun,x,y,dir)
gun:shoot(x,y,dir)
end
-- init guns
--degaplus = 0
--name spr cd spd oa dmg is_enemy auto maxammo sfx knock
--debuggun = make_gun("debuggun, 64, 1, 3, .02, 0, 0, 1, 999999, 64, 1",
-- function(gun,x,y,dir)
-- for i=1,7 do
-- p.life += 1
-- gun:shoot(x,y,dir+rrnd(.1), ospd)
-- end
--end
-- function(gun,x,y,dir)
-- gun:shoot(x,y,dir)
-- end
-- )
function initguns()
guns = {
--name spr cd spd oa dmg is_enemy auto maxammo sfx
revolver = make_gun("revolver, 64, 15,2.5,.02,3 ,0, 0, 100, 33, 0.3",
shoot1
),
fireworklauncher = make_gun("firework launcher, 74, 25,2.5,.02,0.1 ,0, 0, 80, 52, 0.6",
shoot1
),
boxing_glove = make_gun("boxing glove, 72, 18,3.3,.005,1 , 0, 0, 1, 36, -0.96",
function(gun,x,y,dir)
for i=1,7 do
gun:shoot(x,y,dir)
end
p.iframes,gun.ammo = 9,gun.maxammo
end
),
bazooka = make_gun("bazooka, 69, 90,1.5,.007,0 ,0, 0, 20, 33, 4.5",
shoot1
),
flamethrower = make_gun("flamethrower, 70, 2,1.5,.015,0.34 ,0, 1, 1500, 51, 0",
shoot1
),
ringcannon = make_gun("ring cannon, 71, 45,2, .01,3, 0, 0, 50, 32, 0",
function(gun,x,y,dir)
for i=1,20 do
local o=i/20
local ospd=gun.spd*(rnd(.2)+.9)
gun:shoot(x,y,dir+o, ospd)
end
end),
--name spr cd spd oa dmg is_enemy auto maxammo sfx
shotgun = make_gun("shotgun, 65, 60,4, .05,1.25, 0, 0, 50, 32, 0.4",
function(gun,x,y,dir)
for i=1,7 do
local o=rrnd(.05)
local ospd=gun.spd*(rnd(.2)+.9)
gun:shoot(x,y,dir+o, ospd)
end
end),
--name spr cd spd oa dmg is_enemy auto maxammo sfx
machinegun = make_gun("machinegun, 66, 7, 3, .05,2 ,0, 1, 250, 33, .2",
shoot1
),
--name spr cd spd oa dmg is_enemy auto maxammo sfx
assaultrifle = make_gun("assault rifle, 67, 30,4, .02,1 ,0, 1, 75, 33, .3",
function(gun,x,y,dir)
gun.burst = 4
gun.x, gun.y = x, y
gun.dir =dir+(rrnd(1))*gun.oa
gun:shoot(x,y,gun.dir)
end
),
--name spr cd spd oa dmg is_enemy auto maxammo sfx
sniper = make_gun("sniper, 68, 40,7, .0, 5 ,0, 0, 35, 32, 3",
shoot1
),
--name spr cd spd oa dmg is_enemy auto maxammo sfx kb
gatlinggun = make_gun("gatling gun, 73, 3, 3, .08, 2 ,0, 1, 500, 33, 1",
shoot1
),
--name spr cd spd oa dmg is_enemy auto maxammo sfx kb
gunslime = make_gun("gunslime, 64, 100,1.5, .02,2, 1, 1, 250, 32, 0",
function(gun,x,y,dir)
dir+=rrnd(gun.oa)
gun:shoot(x,y,dir)
end
),
--name spr cd spd oa dmg is_enemy auto maxammo sfx
gunslimebuff = make_gun("gunslimebuff, 64, 100,1, .04,2, 1, 1, 250, 32, 0",
function(gun,x,y,dir)
for i=0,2 do
local o=rrnd(.05)
local ospd=gun.spd*(rnd(.2)+.9)
gun:shoot(x,y,dir+o, ospd)
end
end
),
shotgunmechant = make_gun("shotgunmechant, 65, 60,1.35, .04,3, 1, 1, 250, 32, 0",
function(gun,x,y,dir)
for i=1,4 do
local o=rrnd(.05)
local ospd=gun.spd*(rnd(.2)+.9)
gun:shoot(x,y,dir+o, ospd)
end
end
),
null = make_gun("null, 57, 0,57, 0,1, 1, 1, 250, 32,0",
function() --opti: remove args
end),
machinegunmechant = make_gun("machinegunmechant, 66, 5, .75,.05,2, 1, 1,250, 32, 0",
shoot1
),
explosion = make_gun("explosion, 57, 0, 2, 0,5 ,1, 0, 1, 32, 0",
function(gun,x,y,dir)
for i=1,12 do
local o=i/12
gun:shoot(x,y,dir+o)
end
end
),
boss_targetgun =
make_gun("boss target gun, 65, 6, 1.2,.05,2, 1, 1, 250, 47, 0",
shoot1
),
boss_360gun =
make_gun("boss 360 gun, 65, 1, 1, 0,2 ,1, 1, 250, 47, 0",
function(gun,x,y,dir)
gun.dir+=.176666
gun:shoot(x,y,gun.dir)
end
),
boss_enemygun =
make_gun("boss_enemygun, 65, 150, 1, 1,2 ,1, 1, 250, 33, 0",
function(gun,x,y,dir)
sfx(33)
gun.timer = gun.cooldown
if(rnd(2)<1)return spawn_enemy(x,y,enemy.hedgehog)
spawn_enemy(x,y,enemy.hedgehogbuff)
end
),
}
--table of number-indexed guns
iguns={}
for k,v in pairs(guns)do