ship_m:move micro-optimizations
This commit is contained in:
@ -585,17 +585,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
|
||||
|
Reference in New Issue
Block a user