2 Commits

Author SHA1 Message Date
b18b4f885d trig zap gun; fixes
use the trig gun for the zap gun
2025-06-01 17:00:28 -07:00
2fdb8d1a05 trigenometry gun prototype 2025-06-01 16:48:39 -07:00

View File

@ -874,6 +874,54 @@ function gun_base:shoot(x, y)
return true
end
trig_gun = mknew(gun_base.new{
veloc = 1,
aim = 0.75, -- down; 0.25 is up
shot_idx = 0,
-- shots: list<list<[3]num>>
-- describing a cycling
-- firing pattern. shot_idx
-- tracks offset into pattern.
-- each nested list: a burst
-- of shots to fire; takes
-- 1 ammo; sequential
-- each shot: angle (turns,
-- relative to `aim`),
-- velocity, firing x-offset;
-- if velocity is nil, use
-- self.veloc instead;
-- if x-offset is nil, use 0
init = function(self)
if (not self.shots) self.shots = {{{0}}}
end
})
function trig_gun:actually_shoot(x, y)
local shots,veloc,aim,munition = self.shots,self.veloc,self.aim,self.munition
local idx = self.shot_idx % #shots + 1
self.shot_idx = idx
shots = shots[idx]
for s in all(shots) do
local a,v,xo = unpack(s)
v = v or veloc
a += aim
-- todo: switch munition
-- depending on angle
-- (allows for non-round
-- sprites and hitboxes on
-- shots from guns with
-- widely varying angles)
local m = munition.new{}
-- todo: automatically make
-- high velocity shots do
-- multiple collision checks
m.dy = sin(a) * veloc
m.dx = cos(a) * veloc
m:spawn_at(x+(xo or 0), y)
end
end
-->8
-- bullets and guns
@ -892,8 +940,6 @@ zap_e = mknew(bullet_base.new{
y_off = 8,
damage = 1,
dx = 0, -- px/frame
dy = 4,
hitship = const_fxn(true),
@ -902,19 +948,21 @@ zap_e = mknew(bullet_base.new{
zap_p = mknew(zap_e.new{
sprite = 8,
dy = -8,
y_off = 0,
category = player_blt_cat,
})
zap_gun_e = mknew(gun_base.new{
zap_gun_e = mknew(trig_gun.new{
cooldown = 0x0.0020, -- frames between shots
veloc = 4,
munition = zap_e,
})
zap_gun_p = mknew(zap_gun_e.new{
icon = 19,
munition = zap_p,
veloc = 8,
aim = 0.25,
hdr = "mAIN gUN",
})