Compare commits
3 Commits
e4062d3ccd
...
eaea42f993
Author | SHA1 | Date | |
---|---|---|---|
eaea42f993
|
|||
929f47fc78
|
|||
430a0a4b14
|
@ -585,17 +585,22 @@ end
|
|||||||
function ship_m:move()
|
function ship_m:move()
|
||||||
self:refresh_shield()
|
self:refresh_shield()
|
||||||
local dx, dy, shoot_spec1, shoot_spec2 = self:act()
|
local dx, dy, shoot_spec1, shoot_spec2 = self:act()
|
||||||
dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
|
local sg, xm, ym = self.special_guns, self.xmomentum, self.ymomentum
|
||||||
dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
|
dx = self:constrain(self.x, xm, self.xmin, self.xmax, dx)
|
||||||
|
dy = self:constrain(self.y, ym, self.ymin, self.ymax, dy)
|
||||||
self:maybe_shoot(self.main_gun)
|
self:maybe_shoot(self.main_gun)
|
||||||
if (shoot_spec1 and self.special_guns) self:maybe_shoot(self.special_guns[1])
|
if sg then
|
||||||
if (shoot_spec2 and self.special_guns) self:maybe_shoot(self.special_guns[2])
|
if (shoot_spec1) self:maybe_shoot(sg[1])
|
||||||
|
if (shoot_spec2) self:maybe_shoot(sg[2])
|
||||||
|
end
|
||||||
spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
|
spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
|
||||||
self.xmomentum = self:calc_velocity(self.xmomentum, dx)
|
xm = self:calc_velocity(xm, dx)
|
||||||
self.ymomentum = self:calc_velocity(self.ymomentum, dy)
|
ym = self:calc_velocity(ym, dy)
|
||||||
|
|
||||||
self.x += self.xmomentum
|
self.x += xm
|
||||||
self.y += self.ymomentum
|
self.y += ym
|
||||||
|
self.xmomentum = xm
|
||||||
|
self.ymomentum = ym
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -818,10 +823,13 @@ function bullet_base:hitship(_)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function bullet_base:move()
|
function bullet_base:move()
|
||||||
self.x += self.dx
|
local x,y,f = self.x + self.dx, self.y+self.dy,self.f
|
||||||
self.y += self.dy
|
self.x,self.y=x,y
|
||||||
if (self.f) self.f -= 1
|
if f then
|
||||||
return (self.y > 130) or (self.y < -self.height*8) or (self.f and self.f < 0) or (self.x > 128) or (self.x < -self.width*8)
|
self.f = f-1
|
||||||
|
if (f <= 0) return true
|
||||||
|
end
|
||||||
|
return (y> 130) or (y < -(self.height<<3)) or (x > 128) or (x < -(self.width<<3))
|
||||||
end
|
end
|
||||||
|
|
||||||
function bullet_base:draw()
|
function bullet_base:draw()
|
||||||
@ -863,25 +871,20 @@ function gun_base:actually_shoot(x, y)
|
|||||||
self.shot_idx = idx
|
self.shot_idx = idx
|
||||||
shots = shots[idx]
|
shots = shots[idx]
|
||||||
for s in all(shots) do
|
for s in all(shots) do
|
||||||
local a,xo,v = unpack(s)
|
local a,xo,v = s[1]+aim, s[2] or 0, s[3] or veloc
|
||||||
v = v or veloc
|
|
||||||
xo = xo or 0
|
|
||||||
-- reverse x-offset for negative base angle
|
-- reverse x-offset for negative base angle
|
||||||
if (aim < 0) xo = -xo
|
if (aim < 0) xo = -xo
|
||||||
a += aim
|
|
||||||
-- todo: switch munition
|
-- todo: switch munition
|
||||||
-- depending on angle
|
-- depending on angle
|
||||||
-- (allows for non-round
|
-- (allows for non-round
|
||||||
-- sprites and hitboxes on
|
-- sprites and hitboxes on
|
||||||
-- shots from guns with
|
-- shots from guns with
|
||||||
-- widely varying angles)
|
-- widely varying angles)
|
||||||
local m = munition.new{}
|
local m = munition.new{
|
||||||
-- todo: automatically make
|
dx=cos(a)*v,
|
||||||
-- high velocity shots do
|
dy=sin(a)*v
|
||||||
-- multiple collision checks
|
}
|
||||||
m.dy = sin(a) * veloc
|
m:spawn_at(x+xo, y)
|
||||||
m.dx = cos(a) * veloc
|
|
||||||
m:spawn_at(x+(xo or 0), y)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user