Compare commits
	
		
			1 Commits
		
	
	
		
			paths
			...
			silly-shot
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						7e4833d567
	
				 | 
					
					
						
							
								
								
									
										309
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							
							
						
						
									
										309
									
								
								vacuum_gambit.p8
									
									
									
									
									
								
							@@ -194,9 +194,7 @@ function updategame()
 | 
				
			|||||||
  interlude -= 1
 | 
					  interlude -= 1
 | 
				
			||||||
 else
 | 
					 else
 | 
				
			||||||
  current_wave = flotilla.new()
 | 
					  current_wave = flotilla.new()
 | 
				
			||||||
  --current_wave:load(rnd() > 0.5 and 7 or 0, 0, min(ones(waves_complete)\2, 4))
 | 
					  current_wave:load(rnd() > 0.5 and 7 or 0, 0, min(ones(waves_complete)\2, 4))
 | 
				
			||||||
  current_wave:load(0, 0, min(ones(waves_complete)\2, 4))
 | 
					 | 
				
			||||||
  current_wave:update()
 | 
					 | 
				
			||||||
 end
 | 
					 end
 | 
				
			||||||
 events = filtermoved(events)
 | 
					 events = filtermoved(events)
 | 
				
			||||||
 appendmove(events, new_events)
 | 
					 appendmove(events, new_events)
 | 
				
			||||||
@@ -468,7 +466,9 @@ ship_m = mknew{
 | 
				
			|||||||
 -- xmin, xmax, ymin, ymax:
 | 
					 -- xmin, xmax, ymin, ymax:
 | 
				
			||||||
 --   movement constraints
 | 
					 --   movement constraints
 | 
				
			||||||
 --   enforced by `constrain`.
 | 
					 --   enforced by `constrain`.
 | 
				
			||||||
 xmin = 0, xmax = 104, ymin = 0, ymax = 120
 | 
					 xmin = 0, xmax = 104,
 | 
				
			||||||
 | 
					 -- ymin, ymax default to nil
 | 
				
			||||||
 | 
					 --   pship needs more constraint 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ship_m:die()
 | 
					function ship_m:die()
 | 
				
			||||||
@@ -510,10 +510,6 @@ function ship_m:brake_dist(v0)
 | 
				
			|||||||
 return (chunk_zone + overage * (tri_frames + 1)) * sgn(v0), (overage > 0) and tri_frames + 1 or tri_frames
 | 
					 return (chunk_zone + overage * (tri_frames + 1)) * sgn(v0), (overage > 0) and tri_frames + 1 or tri_frames
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ship_m:reset_bounds()
 | 
					 | 
				
			||||||
 self.xmin, self.xmax, self.ymin, self.ymax = 0, 104, 0, 120
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function ship_m:constrain(p, dp, pmin, pmax, want)
 | 
					function ship_m:constrain(p, dp, pmin, pmax, want)
 | 
				
			||||||
 if (not pmin) return want
 | 
					 if (not pmin) return want
 | 
				
			||||||
 local v1, bd, bf, bp
 | 
					 local v1, bd, bf, bp
 | 
				
			||||||
@@ -619,190 +615,6 @@ function ship_m:refresh_shield()
 | 
				
			|||||||
 self.shield_refresh_ready = gframe + self.shieldcooldown
 | 
					 self.shield_refresh_ready = gframe + self.shieldcooldown
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-->8
 | 
					 | 
				
			||||||
-- paths
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- destination: a point the
 | 
					 | 
				
			||||||
-- center of a ship approaches
 | 
					 | 
				
			||||||
destination = mknew{
 | 
					 | 
				
			||||||
 -- 0..1: a point on a line
 | 
					 | 
				
			||||||
 -- segment from the ship's
 | 
					 | 
				
			||||||
 -- flotilla spot to the player;
 | 
					 | 
				
			||||||
 -- -1 means center of play area
 | 
					 | 
				
			||||||
 anchor_frac=0,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 -- (0, 1]: relative to max
 | 
					 | 
				
			||||||
 -- acceleration, how quickly
 | 
					 | 
				
			||||||
 -- should the ship accelerate
 | 
					 | 
				
			||||||
 -- to its destination?
 | 
					 | 
				
			||||||
 -- 0: park here instead, using
 | 
					 | 
				
			||||||
 -- constraint following
 | 
					 | 
				
			||||||
 accel_frac=1,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 -- how far to lerp between the
 | 
					 | 
				
			||||||
 -- anchor and the screen bounds.
 | 
					 | 
				
			||||||
 -- this is the "destination"-y
 | 
					 | 
				
			||||||
 -- part of a destination.
 | 
					 | 
				
			||||||
 x_off_frac = 0,
 | 
					 | 
				
			||||||
 y_off_frac = 0
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function lerp(a, b, f)
 | 
					 | 
				
			||||||
 return (1-f)*a+b*f
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function destination:anchor(fx, fy)
 | 
					 | 
				
			||||||
 local af = self.anchor_frac
 | 
					 | 
				
			||||||
 if (af == -1) return 51,59
 | 
					 | 
				
			||||||
 return lerp(fx, primary_ship.x, af), lerp(fy, primary_ship.y, af)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function destination:target_from(fx, fy)
 | 
					 | 
				
			||||||
 local rx, ry = self:anchor(fx, fy)
 | 
					 | 
				
			||||||
 local xf, yf = self.x_off_frac, self.y_off_frac
 | 
					 | 
				
			||||||
 if (xf < 0) rx = lerp(rx, 0, -xf)
 | 
					 | 
				
			||||||
 if (xf > 0) rx = lerp(rx, 104, xf)
 | 
					 | 
				
			||||||
 if (yf < 0) ry = lerp(ry, 0, -yf)
 | 
					 | 
				
			||||||
 if (yf > 0) ry = lerp(ry, 120, yf)
 | 
					 | 
				
			||||||
 return rx, ry, self.accel_frac
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
segment = mknew{
 | 
					 | 
				
			||||||
 -- On loop, where to set index?
 | 
					 | 
				
			||||||
 loop_idx = 1,
 | 
					 | 
				
			||||||
 -- current index
 | 
					 | 
				
			||||||
 current_idx = 1,
 | 
					 | 
				
			||||||
 -- how long does this segment
 | 
					 | 
				
			||||||
 -- last? 0 is erroneous,
 | 
					 | 
				
			||||||
 -- positive values are a frame
 | 
					 | 
				
			||||||
 -- count, negative values are
 | 
					 | 
				
			||||||
 -- a number of loops.
 | 
					 | 
				
			||||||
 limit = -1,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 -- remain: remaining steps until end
 | 
					 | 
				
			||||||
 -- prev_x, prev_y: stored previous
 | 
					 | 
				
			||||||
 --  location to figure out
 | 
					 | 
				
			||||||
 --  approach/depart
 | 
					 | 
				
			||||||
 -- dest_x, dest_y: stored
 | 
					 | 
				
			||||||
 --  current destination to
 | 
					 | 
				
			||||||
 --  figure out approach/depart
 | 
					 | 
				
			||||||
 -- dests[1..n]: destinations
 | 
					 | 
				
			||||||
 init = function(x)
 | 
					 | 
				
			||||||
  x.init = segment.reset
 | 
					 | 
				
			||||||
  mknew(x)
 | 
					 | 
				
			||||||
  if not x.mirror then
 | 
					 | 
				
			||||||
   local mdests = {}
 | 
					 | 
				
			||||||
   for i, v in ipairs(x.dests) do
 | 
					 | 
				
			||||||
    mdests[i] = destination.new{
 | 
					 | 
				
			||||||
     anchor_frac=v.anchor_frac,
 | 
					 | 
				
			||||||
     accel_frac=v.accel_frac,
 | 
					 | 
				
			||||||
     x_off_frac=-v.x_off_frac,
 | 
					 | 
				
			||||||
     y_off_frac=v.y_off_frac,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
   end
 | 
					 | 
				
			||||||
   x.mirror = mknew(x.new{mirror=x, init=segment.reset, dests=mdests})
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function segment:reset()
 | 
					 | 
				
			||||||
 self.current_idx = 1
 | 
					 | 
				
			||||||
 self.remain = self.limit
 | 
					 | 
				
			||||||
 self.prev_x = false
 | 
					 | 
				
			||||||
 self.prev_y = false
 | 
					 | 
				
			||||||
 self.was_approaching = false
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function segment:target_from(fx, fy)
 | 
					 | 
				
			||||||
 local rx, ry, af = self.dests[self.current_idx]:target_from(fx, fy)
 | 
					 | 
				
			||||||
 self.dest_x, self.dest_y = rx, ry
 | 
					 | 
				
			||||||
 return rx, ry, af
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function segment:update(x, y)
 | 
					 | 
				
			||||||
 local rem = self.remain
 | 
					 | 
				
			||||||
 -- frame check
 | 
					 | 
				
			||||||
 if (rem > 0) rem -= 1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 if self:should_step(x, y) then
 | 
					 | 
				
			||||||
  self.prev_x, self.prev_y, self.was_approaching = false, false, false
 | 
					 | 
				
			||||||
  if self.current_idx == #self.dests then
 | 
					 | 
				
			||||||
   self.current_idx = self.loop_idx
 | 
					 | 
				
			||||||
   if (rem < 0) rem += 1
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
   self.current_idx += 1
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 self.remain = rem
 | 
					 | 
				
			||||||
 return rem != 0
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function segment:should_step(x, y)
 | 
					 | 
				
			||||||
 local dest_x, dest_y = self.dest_x, self.dest_y
 | 
					 | 
				
			||||||
 local dx1, dy1 = x - dest_x, y-dest_y
 | 
					 | 
				
			||||||
 if (abs(dx1) <= 1.5 and abs(dy1) <= 1.5) return true
 | 
					 | 
				
			||||||
 if self.prev_x then
 | 
					 | 
				
			||||||
  local dx0, dy0 = self.prev_x - dest_x, self.prev_y - dest_y
 | 
					 | 
				
			||||||
  local d12, d02 = dx1 * dx1 + dy1 * dy1, dx0 * dx0 + dy0 * dy0
 | 
					 | 
				
			||||||
  if d12 > d02 then
 | 
					 | 
				
			||||||
   if (self.was_approaching) return true
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
   if (d12 == d02 and self.was_approaching) return true
 | 
					 | 
				
			||||||
   self.was_approaching = true
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 self.prev_x, self.prev_y = x, y
 | 
					 | 
				
			||||||
 return false
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
path = mknew {
 | 
					 | 
				
			||||||
 loop_idx = 1,
 | 
					 | 
				
			||||||
 -- segs[1..n]: segments or subpaths
 | 
					 | 
				
			||||||
 init=function(x)
 | 
					 | 
				
			||||||
  if not x.mirror then
 | 
					 | 
				
			||||||
   local msegs = {}
 | 
					 | 
				
			||||||
   for i, v in ipairs(x.segs) do
 | 
					 | 
				
			||||||
    msegs[i]=v.mirror
 | 
					 | 
				
			||||||
   end
 | 
					 | 
				
			||||||
   x.mirror = path.new{mirror=x, loop_idx=x.loop_idx, segs=msegs}
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
  x.init = function(y)
 | 
					 | 
				
			||||||
   local ysegs = {}
 | 
					 | 
				
			||||||
   for i, v in ipairs(x.segs) do
 | 
					 | 
				
			||||||
    ysegs[i]=v.new{}
 | 
					 | 
				
			||||||
   end
 | 
					 | 
				
			||||||
   y.segs = ysegs
 | 
					 | 
				
			||||||
   y:reset()
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
  mknew(x)
 | 
					 | 
				
			||||||
 end,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function path:reset()
 | 
					 | 
				
			||||||
 self.current_idx = 1
 | 
					 | 
				
			||||||
 for s in all(self.segs) do
 | 
					 | 
				
			||||||
  s:reset()
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function path:target_from(fx, fy)
 | 
					 | 
				
			||||||
 return self.segs[self.current_idx]:target_from(fx, fy)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function path:update(x, y)
 | 
					 | 
				
			||||||
 local idx, segs = self.current_idx, self.segs
 | 
					 | 
				
			||||||
 if not segs[idx]:update(x, y) then
 | 
					 | 
				
			||||||
  segs[idx]:reset()
 | 
					 | 
				
			||||||
  if idx == #segs then
 | 
					 | 
				
			||||||
   self.current_idx = self.loop_idx
 | 
					 | 
				
			||||||
   return
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
   self.current_idx = idx+1
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 return true
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-->8
 | 
					-->8
 | 
				
			||||||
-- bullet and gun behaviors
 | 
					-- bullet and gun behaviors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1210,7 +1022,7 @@ machine_gun_e = mknew(vulcan_gun_e.new{
 | 
				
			|||||||
 icon = 38,
 | 
					 icon = 38,
 | 
				
			||||||
 clip_size = 12,
 | 
					 clip_size = 12,
 | 
				
			||||||
 clip_interval = 0x0.005a,
 | 
					 clip_interval = 0x0.005a,
 | 
				
			||||||
 shots = {{{0, 2}}, {{0, -2}}}
 | 
					 shots = {{{0.0625, 2}}, {{-0.0625, -2}}}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vulcan_gun_p = mknew(vulcan_gun_e.new{
 | 
					vulcan_gun_p = mknew(vulcan_gun_e.new{
 | 
				
			||||||
@@ -1252,8 +1064,8 @@ player = mknew(ship_m.new{
 | 
				
			|||||||
 boss = true,  -- dramatic special effects
 | 
					 boss = true,  -- dramatic special effects
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 -- health
 | 
					 -- health
 | 
				
			||||||
 hp = 3, -- current health, non-regenerating
 | 
					 hp = 1024, -- current health, non-regenerating
 | 
				
			||||||
 maxhp = 3, -- player only; other ships never heal
 | 
					 maxhp = 1024, -- player only; other ships never heal
 | 
				
			||||||
 shield = 2, -- regenerates
 | 
					 shield = 2, -- regenerates
 | 
				
			||||||
 maxshield = 2,
 | 
					 maxshield = 2,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1277,6 +1089,7 @@ player = mknew(ship_m.new{
 | 
				
			|||||||
 ymomentum = 0,
 | 
					 ymomentum = 0,
 | 
				
			||||||
 maxspd = 1.5, -- momentum cap
 | 
					 maxspd = 1.5, -- momentum cap
 | 
				
			||||||
 thrust = 0.1875, -- momentum added from button
 | 
					 thrust = 0.1875, -- momentum added from button
 | 
				
			||||||
 | 
					 ymin = 0, ymax = 120, -- stay on screen
 | 
				
			||||||
 drag = 0.0625, -- momentum lost per frame
 | 
					 drag = 0.0625, -- momentum lost per frame
 | 
				
			||||||
 act = function(self)  -- fetch buttons
 | 
					 act = function(self)  -- fetch buttons
 | 
				
			||||||
  local b,th = btn(),self.thrust
 | 
					  local b,th = btn(),self.thrust
 | 
				
			||||||
@@ -1490,76 +1303,13 @@ ship_f = mknew(ship_m.new{
 | 
				
			|||||||
 act = function(self)
 | 
					 act = function(self)
 | 
				
			||||||
  local wx,wy=self.want_x,self.want_y
 | 
					  local wx,wy=self.want_x,self.want_y
 | 
				
			||||||
  self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
 | 
					  self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
 | 
				
			||||||
  return 0,0
 | 
					  return 0,0,false,false
 | 
				
			||||||
 end,
 | 
					 end,
 | 
				
			||||||
 init = function(self)
 | 
					 init = function(self)
 | 
				
			||||||
  if (self.gun_proto) self.main_gun = self.gun_proto.new()
 | 
					  if (self.gun_proto) self.main_gun = self.gun_proto.new()
 | 
				
			||||||
  if (self.path) self.path = self.path.new()
 | 
					 | 
				
			||||||
 end
 | 
					 end
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
diamond_loop = segment.new{
 | 
					 | 
				
			||||||
 dests = {
 | 
					 | 
				
			||||||
  destination.new{
 | 
					 | 
				
			||||||
   x_off_frac=0.125
 | 
					 | 
				
			||||||
  }, destination.new{
 | 
					 | 
				
			||||||
   y_off_frac=0.125
 | 
					 | 
				
			||||||
  }, destination.new {
 | 
					 | 
				
			||||||
   x_off_frac = -0.125
 | 
					 | 
				
			||||||
  }, destination.new {
 | 
					 | 
				
			||||||
   y_off_frac = -0.125
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
 },
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
park = segment.new{
 | 
					 | 
				
			||||||
 dests = {
 | 
					 | 
				
			||||||
  destination.new{
 | 
					 | 
				
			||||||
   accel_frac = 0
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
diamond_bounce = path.new{
 | 
					 | 
				
			||||||
 segs = {
 | 
					 | 
				
			||||||
  park,
 | 
					 | 
				
			||||||
  diamond_loop,
 | 
					 | 
				
			||||||
  park,
 | 
					 | 
				
			||||||
  diamond_loop.mirror,
 | 
					 | 
				
			||||||
 },
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
swoop = segment.new {
 | 
					 | 
				
			||||||
 dests = {
 | 
					 | 
				
			||||||
  destination.new{
 | 
					 | 
				
			||||||
   accel_frac = 0
 | 
					 | 
				
			||||||
  }, destination.new{
 | 
					 | 
				
			||||||
   x_off_frac = -0.75,
 | 
					 | 
				
			||||||
   anchor_frac = 0.25,
 | 
					 | 
				
			||||||
  }, destination.new {
 | 
					 | 
				
			||||||
   x_off_frac = -0.375,
 | 
					 | 
				
			||||||
   anchor_frac = 0.625,
 | 
					 | 
				
			||||||
  }, destination.new {
 | 
					 | 
				
			||||||
   y_off_frac = -0.125,
 | 
					 | 
				
			||||||
   anchor_frac = 1,
 | 
					 | 
				
			||||||
  }, destination.new {
 | 
					 | 
				
			||||||
   x_off_frac = 0.375,
 | 
					 | 
				
			||||||
   anchor_frac = 0.625,
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
 },
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
swoop_loop = path.new {
 | 
					 | 
				
			||||||
 segs = {
 | 
					 | 
				
			||||||
  diamond_loop,
 | 
					 | 
				
			||||||
  swoop,
 | 
					 | 
				
			||||||
  park,
 | 
					 | 
				
			||||||
  diamond_loop.mirror,
 | 
					 | 
				
			||||||
  swoop.mirror,
 | 
					 | 
				
			||||||
  park,
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ship_mook = mknew(ship_f.new{
 | 
					ship_mook = mknew(ship_f.new{
 | 
				
			||||||
 sprite=103
 | 
					 sprite=103
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@@ -1576,37 +1326,11 @@ ship_turret = mknew(ship_f.new{
 | 
				
			|||||||
ship_skirmisher = mknew(ship_f.new{
 | 
					ship_skirmisher = mknew(ship_f.new{
 | 
				
			||||||
 sprite=107,
 | 
					 sprite=107,
 | 
				
			||||||
 xp = 0x0.0004,
 | 
					 xp = 0x0.0004,
 | 
				
			||||||
 hp = 1.5,
 | 
					 | 
				
			||||||
 sparks = smokespark,
 | 
					 sparks = smokespark,
 | 
				
			||||||
 sparkodds = 3,
 | 
					 sparkodds = 3,
 | 
				
			||||||
 fire_off_y = 7,
 | 
					 fire_off_y = 7,
 | 
				
			||||||
 xmin = -8,
 | 
					 | 
				
			||||||
 xmax = 112,
 | 
					 | 
				
			||||||
 path = swoop_loop,
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ship_skirmisher:reset_bounds()
 | 
					 | 
				
			||||||
 self.xmin, self.xmax, self.ymin, self.ymax = -8, 112, 0, 128
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function ship_skirmisher:act()
 | 
					 | 
				
			||||||
 local tx, ty, af = self.path:target_from(self.want_x, self.want_y)
 | 
					 | 
				
			||||||
 if af <= 0 then
 | 
					 | 
				
			||||||
  self.xmin, self.xmax, self.ymin, self.ymax = tx,tx,ty,ty
 | 
					 | 
				
			||||||
  return 0,0
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 self:reset_bounds()
 | 
					 | 
				
			||||||
 local ax, ay, th = tx - self.x, ty - self.y, self.thrust*af
 | 
					 | 
				
			||||||
 local ma = max(abs(ax), abs(ay))
 | 
					 | 
				
			||||||
 return ax*th/ma, ay*th/ma
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function ship_skirmisher:move()
 | 
					 | 
				
			||||||
 if (not ship_f.move(self)) return
 | 
					 | 
				
			||||||
 if (not self.path:update(self.x, self.y)) self.path:reset()
 | 
					 | 
				
			||||||
 return true
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function rnd_spawn_loc()
 | 
					function rnd_spawn_loc()
 | 
				
			||||||
 local x,y = flr(rnd(304)), flr(rnd(32))
 | 
					 local x,y = flr(rnd(304)), flr(rnd(32))
 | 
				
			||||||
 if (x<184) return x-40,-y-8
 | 
					 if (x<184) return x-40,-y-8
 | 
				
			||||||
@@ -1707,7 +1431,7 @@ flotilla = mknew{
 | 
				
			|||||||
   [8]=mknew(ship_turret.new{ship_t=8}),
 | 
					   [8]=mknew(ship_turret.new{ship_t=8}),
 | 
				
			||||||
   [9]=mknew(ship_turret.new{ship_t=9, sprite=4}),
 | 
					   [9]=mknew(ship_turret.new{ship_t=9, sprite=4}),
 | 
				
			||||||
   [12]=mknew(ship_skirmisher.new{ship_t=12}),
 | 
					   [12]=mknew(ship_skirmisher.new{ship_t=12}),
 | 
				
			||||||
   [13]=mknew(ship_skirmisher.new{ship_t=13, sprite=26, path=diamond_bounce}),
 | 
					   [13]=mknew(ship_skirmisher.new{ship_t=13, sprite=26}),
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 end,
 | 
					 end,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1723,7 +1447,6 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
 | 
				
			|||||||
  [12]=0,
 | 
					  [12]=0,
 | 
				
			||||||
  [13]=0,
 | 
					  [13]=0,
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 local maxcol = 0
 | 
					 | 
				
			||||||
 repeat
 | 
					 repeat
 | 
				
			||||||
  local row,cx,opt,f,mode= {},ulc_cx,{},0,0
 | 
					  local row,cx,opt,f,mode= {},ulc_cx,{},0,0
 | 
				
			||||||
  for i,v in ipairs(self.opt_odds) do
 | 
					  for i,v in ipairs(self.opt_odds) do
 | 
				
			||||||
@@ -1735,7 +1458,7 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
 | 
				
			|||||||
   mode = f&0x03
 | 
					   mode = f&0x03
 | 
				
			||||||
   if mode==2 then
 | 
					   if mode==2 then
 | 
				
			||||||
    -- bits 0x0c: ship class
 | 
					    -- bits 0x0c: ship class
 | 
				
			||||||
    local ship_t, col = f&0x0c, cx-ulc_cx
 | 
					    local ship_t = f&0x0c
 | 
				
			||||||
    -- bit 0x20: optional?
 | 
					    -- bit 0x20: optional?
 | 
				
			||||||
    if f&0x20 == 0 or opt[ship_t] then
 | 
					    if f&0x20 == 0 or opt[ship_t] then
 | 
				
			||||||
     -- bit 0x10: alternate ship?
 | 
					     -- bit 0x10: alternate ship?
 | 
				
			||||||
@@ -1744,8 +1467,7 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
 | 
				
			|||||||
     -- and we allow alternates
 | 
					     -- and we allow alternates
 | 
				
			||||||
     -- for this type of ship
 | 
					     -- for this type of ship
 | 
				
			||||||
     ship_t+=(uv>>ship_t&0x1)&((f&0x10)>>4)
 | 
					     ship_t+=(uv>>ship_t&0x1)&((f&0x10)>>4)
 | 
				
			||||||
     add(row, self.ship_bases[ship_t].new{col=col})
 | 
					     add(row, self.ship_bases[ship_t].new{col=cx-ulc_cx})
 | 
				
			||||||
     if (col > maxcol) maxcol = col
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
   end
 | 
					   end
 | 
				
			||||||
   cx += 1
 | 
					   cx += 1
 | 
				
			||||||
@@ -1765,13 +1487,6 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
 | 
				
			|||||||
  -- control mark bit 0x04: end of flotilla
 | 
					  -- control mark bit 0x04: end of flotilla
 | 
				
			||||||
 until f&0x04 > 0
 | 
					 until f&0x04 > 0
 | 
				
			||||||
 self.rows=rows
 | 
					 self.rows=rows
 | 
				
			||||||
 -- mirror right half paths; alternate center column if odd
 | 
					 | 
				
			||||||
 local rh = maxcol>>1
 | 
					 | 
				
			||||||
 for r, row in ipairs(rows) do
 | 
					 | 
				
			||||||
  for s in all(row) do
 | 
					 | 
				
			||||||
   if ((s.path) and (s.col > rh or (s.col == rh and r & 1 == 1))) s.path = s.path.mirror.new()
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 self:statisfy(counts)
 | 
					 self:statisfy(counts)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user