Compare commits
4 Commits
e4062d3ccd
...
okay_slow_
Author | SHA1 | Date | |
---|---|---|---|
67970a5164
|
|||
eaea42f993
|
|||
929f47fc78
|
|||
430a0a4b14
|
@ -199,6 +199,7 @@ end
|
||||
|
||||
function _update60()
|
||||
mode:update()
|
||||
ustat = stat(1)
|
||||
end
|
||||
|
||||
function ones(n)
|
||||
@ -295,6 +296,8 @@ end
|
||||
|
||||
function _draw()
|
||||
mode:draw()
|
||||
local ds = stat(1)
|
||||
print(tostr(ustat).." + "..tostr(ds-ustat), 0, 122, 7)
|
||||
end
|
||||
|
||||
function drawgame_top()
|
||||
@ -585,17 +588,22 @@ end
|
||||
function ship_m:move()
|
||||
self:refresh_shield()
|
||||
local dx, dy, shoot_spec1, shoot_spec2 = self:act()
|
||||
dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
|
||||
dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
|
||||
local sg, xm, ym = self.special_guns, self.xmomentum, self.ymomentum
|
||||
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)
|
||||
if (shoot_spec1 and self.special_guns) self:maybe_shoot(self.special_guns[1])
|
||||
if (shoot_spec2 and self.special_guns) self:maybe_shoot(self.special_guns[2])
|
||||
if sg then
|
||||
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)
|
||||
self.xmomentum = self:calc_velocity(self.xmomentum, dx)
|
||||
self.ymomentum = self:calc_velocity(self.ymomentum, dy)
|
||||
xm = self:calc_velocity(xm, dx)
|
||||
ym = self:calc_velocity(ym, dy)
|
||||
|
||||
self.x += self.xmomentum
|
||||
self.y += self.ymomentum
|
||||
self.x += xm
|
||||
self.y += ym
|
||||
self.xmomentum = xm
|
||||
self.ymomentum = ym
|
||||
|
||||
return false
|
||||
end
|
||||
@ -818,10 +826,13 @@ function bullet_base:hitship(_)
|
||||
end
|
||||
|
||||
function bullet_base:move()
|
||||
self.x += self.dx
|
||||
self.y += self.dy
|
||||
if (self.f) self.f -= 1
|
||||
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)
|
||||
local x,y,f = self.x + self.dx, self.y+self.dy,self.f
|
||||
self.x,self.y=x,y
|
||||
if f then
|
||||
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
|
||||
|
||||
function bullet_base:draw()
|
||||
@ -863,25 +874,20 @@ function gun_base:actually_shoot(x, y)
|
||||
self.shot_idx = idx
|
||||
shots = shots[idx]
|
||||
for s in all(shots) do
|
||||
local a,xo,v = unpack(s)
|
||||
v = v or veloc
|
||||
xo = xo or 0
|
||||
local a,xo,v = s[1]+aim, s[2] or 0, s[3] or veloc
|
||||
-- reverse x-offset for negative base angle
|
||||
if (aim < 0) xo = -xo
|
||||
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)
|
||||
local m = munition.new{
|
||||
dx=cos(a)*v,
|
||||
dy=sin(a)*v
|
||||
}
|
||||
m:spawn_at(x+xo, y)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user