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