Compare commits
16 Commits
904fbe6b2e
...
paths
Author | SHA1 | Date | |
---|---|---|---|
1d816e0c6a
|
|||
be321db355
|
|||
7c3fc833df
|
|||
10aef3b1ed
|
|||
6efd05febe
|
|||
383491fc5d
|
|||
8533720114
|
|||
797818214a
|
|||
ee24adf8b2
|
|||
0b98ee540d
|
|||
9d02a1f570
|
|||
c752e8e1e3
|
|||
507f06fb8c
|
|||
14849101dd
|
|||
2cd7c64dd9
|
|||
2d5d392df0
|
407
vacuum_gambit.p8
407
vacuum_gambit.p8
@@ -61,11 +61,11 @@ end
|
||||
|
||||
-- call f on everything on list
|
||||
-- and return a new list of
|
||||
-- items for which f was false.
|
||||
function stripped(list, f)
|
||||
-- items for which f was true.
|
||||
function filtered(list, f)
|
||||
local ret, n = {}, 0
|
||||
for v in all(list) do
|
||||
if not f(v) then
|
||||
if f(v) then
|
||||
n += 1
|
||||
ret[n] = v
|
||||
end
|
||||
@@ -75,25 +75,25 @@ end
|
||||
|
||||
-- call :move on everything on
|
||||
-- src and dump everything
|
||||
-- for which it returned false
|
||||
-- for which it returned true
|
||||
-- onto dest.
|
||||
function appendmove(dest, src)
|
||||
local n = #dest
|
||||
for v in all(src) do
|
||||
if not v:move() then
|
||||
if v:move() then
|
||||
n += 1
|
||||
dest[n] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- like stripped, but calls
|
||||
-- like filtered, but calls
|
||||
-- :move on stuff in the list
|
||||
-- instead of taking a func arg.
|
||||
function stripmoved(list)
|
||||
function filtermoved(list)
|
||||
local ret, n = {}, 0
|
||||
for v in all(list) do
|
||||
if not v:move() then
|
||||
if v:move() then
|
||||
n += 1
|
||||
ret[n] = v
|
||||
end
|
||||
@@ -130,7 +130,7 @@ hpcols_lut = csv[[36
|
||||
-- call after any change to maxhp
|
||||
-- configures health gradient
|
||||
function init_hpcols()
|
||||
hpcols = hpcols_lut[min(primary_ship.maxhp,6)]
|
||||
hpcols = hpcols_lut[min(primary_ship.maxhp,5)]
|
||||
end
|
||||
|
||||
function wipe_game()
|
||||
@@ -194,13 +194,15 @@ function updategame()
|
||||
interlude -= 1
|
||||
else
|
||||
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
|
||||
events = stripmoved(events)
|
||||
events = filtermoved(events)
|
||||
appendmove(events, new_events)
|
||||
new_events = {}
|
||||
intangibles_bg = stripmoved(intangibles_bg)
|
||||
eships = stripmoved(eships)
|
||||
intangibles_bg = filtermoved(intangibles_bg)
|
||||
eships = filtermoved(eships)
|
||||
|
||||
-- eship collider will be used
|
||||
-- both for pship and pbullets.
|
||||
@@ -213,25 +215,26 @@ function updategame()
|
||||
ps:hitship(es)
|
||||
es:hitship(ps)
|
||||
end
|
||||
ebullets = stripped(ebullets, function(eb)
|
||||
if (eb:move()) return true
|
||||
if (not collides(pbox, hurtbox(eb))) return
|
||||
ebullets = filtered(ebullets, function(eb)
|
||||
if (not eb:move()) return
|
||||
if (not collides(pbox, hurtbox(eb))) return true
|
||||
ps:hitbullet(eb)
|
||||
return eb:hitship(ps)
|
||||
return not eb:hitship(ps)
|
||||
end)
|
||||
else
|
||||
ebullets=stripmoved(ebullets)
|
||||
ebullets=filtermoved(ebullets)
|
||||
end
|
||||
|
||||
pbullets = stripped(pbullets, function(pb)
|
||||
if (pb:move()) return true
|
||||
pbullets = filtered(pbullets, function(pb)
|
||||
if (not pb:move()) return
|
||||
for es in eship_collider:iterate_collisions(hurtbox(pb)) do
|
||||
es:hitbullet(pb)
|
||||
if (pb:hitship(es)) return true
|
||||
if (pb:hitship(es)) return
|
||||
end
|
||||
return true
|
||||
end)
|
||||
|
||||
intangibles_fg = stripmoved(intangibles_fg)
|
||||
intangibles_fg = filtermoved(intangibles_fg)
|
||||
|
||||
if waves_complete == 32767 and #eships == 0 and #ebullets == 0 and #events == 0 then
|
||||
game_state = win
|
||||
@@ -465,9 +468,7 @@ ship_m = mknew{
|
||||
-- xmin, xmax, ymin, ymax:
|
||||
-- movement constraints
|
||||
-- enforced by `constrain`.
|
||||
xmin = 0, xmax = 104,
|
||||
-- ymin, ymax default to nil
|
||||
-- pship needs more constraint
|
||||
xmin = 0, xmax = 104, ymin = 0, ymax = 120
|
||||
}
|
||||
|
||||
function ship_m:die()
|
||||
@@ -509,6 +510,10 @@ function ship_m:brake_dist(v0)
|
||||
return (chunk_zone + overage * (tri_frames + 1)) * sgn(v0), (overage > 0) and tri_frames + 1 or tri_frames
|
||||
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)
|
||||
if (not pmin) return want
|
||||
local v1, bd, bf, bp
|
||||
@@ -535,10 +540,10 @@ function ship_m:constrain(p, dp, pmin, pmax, want)
|
||||
end
|
||||
|
||||
function ship_m:move()
|
||||
if (self.dead) return true;
|
||||
if (self.dead) return;
|
||||
self:refresh_shield()
|
||||
local dx, dy, shoot_spec1, shoot_spec2 = self:act()
|
||||
local sg, xm, ym = self.special_guns, self.xmomentum, self.ymomentum
|
||||
local sg, xm, ym, sp = self.special_guns, self.xmomentum, self.ymomentum, self.sparks
|
||||
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)
|
||||
@@ -546,7 +551,7 @@ function ship_m:move()
|
||||
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)
|
||||
if(sp) spark(sp, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
|
||||
xm = self:calc_velocity(xm, dx)
|
||||
ym = self:calc_velocity(ym, dy)
|
||||
|
||||
@@ -555,7 +560,7 @@ function ship_m:move()
|
||||
self.xmomentum = xm
|
||||
self.ymomentum = ym
|
||||
|
||||
return false
|
||||
return true
|
||||
end
|
||||
|
||||
function ship_m:draw()
|
||||
@@ -614,17 +619,193 @@ function ship_m:refresh_shield()
|
||||
self.shield_refresh_ready = gframe + self.shieldcooldown
|
||||
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
|
||||
-- bullet and gun behaviors
|
||||
|
||||
function player_blt_cat()
|
||||
return pbullets
|
||||
end
|
||||
|
||||
function enemy_blt_cat()
|
||||
return ebullets
|
||||
end
|
||||
|
||||
-- x, y: position
|
||||
-- dx, dy: movement (linear)
|
||||
-- f: frames remaining; nil for no limit
|
||||
@@ -637,9 +818,9 @@ end
|
||||
-- details, check impl
|
||||
-- damage -- damage to do to
|
||||
-- a ship that gets hit
|
||||
-- category -- function that
|
||||
-- returns which bullet list
|
||||
-- to spawn onto
|
||||
-- category -- string naming
|
||||
-- which bullet list to spawn
|
||||
-- onto, from _ENV
|
||||
-- hitship -- event handler,
|
||||
-- takes ship as argument.
|
||||
-- default: die, return true.
|
||||
@@ -774,7 +955,7 @@ end
|
||||
function bullet_base:move()
|
||||
local x,y = self.x + self.dx, self.y+self.dy
|
||||
self.x,self.y=x,y
|
||||
return (y>128) or (y < -(self.height<<3)) or (x > 128) or (x < -(self.width<<3))
|
||||
return (y<=128) and (y >= -16) and (x <= 128) and (x >= -16)
|
||||
end
|
||||
|
||||
function bullet_base:draw()
|
||||
@@ -784,7 +965,7 @@ end
|
||||
function bullet_base:spawn_at(x, y)
|
||||
self.x = x - self.x_off
|
||||
self.y = y - self.y_off
|
||||
add(self.category(), self)
|
||||
add(_ENV[self.category], self)
|
||||
end
|
||||
|
||||
function gun_base:shoot(x, y)
|
||||
@@ -854,7 +1035,7 @@ zap_p = mknew(bullet_base.new{
|
||||
|
||||
hitship = const_fxn(true),
|
||||
|
||||
category = player_blt_cat,
|
||||
category = "pbullets",
|
||||
})
|
||||
|
||||
zap_gun_p = mknew(gun_base.new{
|
||||
@@ -913,7 +1094,7 @@ blast = mknew(bullet_base.new{
|
||||
end)
|
||||
end
|
||||
end,
|
||||
category=player_blt_cat
|
||||
category="pbullets"
|
||||
})
|
||||
|
||||
blast_gun = mknew(gun_base.new{
|
||||
@@ -952,14 +1133,14 @@ protron_e = mknew(bullet_base.new{
|
||||
y_off = 4,
|
||||
|
||||
damage = 1,
|
||||
category = enemy_blt_cat,
|
||||
category = "ebullets",
|
||||
})
|
||||
|
||||
protron_p = mknew(protron_e.new{
|
||||
sprite=23,
|
||||
dym = -1,
|
||||
y_off = 0,
|
||||
category=player_blt_cat,
|
||||
category="pbullets",
|
||||
})
|
||||
|
||||
protron_gun_e = mknew(gun_base.new{
|
||||
@@ -1006,13 +1187,13 @@ vulcan_e = mknew(bullet_base.new{
|
||||
y_off = 0,
|
||||
|
||||
damage = 0.5,
|
||||
category=enemy_blt_cat
|
||||
category="ebullets"
|
||||
})
|
||||
|
||||
vulcan_p = mknew(vulcan_e.new{
|
||||
sprite=22,
|
||||
y_off = 4,
|
||||
category=player_blt_cat
|
||||
category="pbullets"
|
||||
})
|
||||
|
||||
vulcan_gun_e = mknew(gun_base.new{
|
||||
@@ -1096,7 +1277,6 @@ player = mknew(ship_m.new{
|
||||
ymomentum = 0,
|
||||
maxspd = 1.5, -- momentum cap
|
||||
thrust = 0.1875, -- momentum added from button
|
||||
ymin = 0, ymax = 120, -- stay on screen
|
||||
drag = 0.0625, -- momentum lost per frame
|
||||
act = function(self) -- fetch buttons
|
||||
local b,th = btn(),self.thrust
|
||||
@@ -1310,13 +1490,76 @@ ship_f = mknew(ship_m.new{
|
||||
act = function(self)
|
||||
local wx,wy=self.want_x,self.want_y
|
||||
self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
|
||||
return 0,0,false,false
|
||||
return 0,0
|
||||
end,
|
||||
init = function(self)
|
||||
if (self.gun_proto) self.main_gun = self.gun_proto.new()
|
||||
if (self.path) self.path = self.path.new()
|
||||
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{
|
||||
sprite=103
|
||||
})
|
||||
@@ -1333,11 +1576,37 @@ ship_turret = mknew(ship_f.new{
|
||||
ship_skirmisher = mknew(ship_f.new{
|
||||
sprite=107,
|
||||
xp = 0x0.0004,
|
||||
hp = 1.5,
|
||||
sparks = smokespark,
|
||||
sparkodds = 3,
|
||||
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()
|
||||
local x,y = flr(rnd(304)), flr(rnd(32))
|
||||
if (x<184) return x-40,-y-8
|
||||
@@ -1350,11 +1619,11 @@ end
|
||||
|
||||
-- box: x1, y1, x2, y2
|
||||
function collides(b1, b2)
|
||||
return
|
||||
b1.x1<=b2.x2
|
||||
and b1.y1<=b2.y2
|
||||
and b1.x2>=b2.x1
|
||||
return
|
||||
b1.y1<=b2.y2
|
||||
and b1.y2>=b2.y1
|
||||
and b1.x1<=b2.x2
|
||||
and b1.x2>=b2.x1
|
||||
end
|
||||
|
||||
collider = mknew{
|
||||
@@ -1438,7 +1707,7 @@ flotilla = mknew{
|
||||
[8]=mknew(ship_turret.new{ship_t=8}),
|
||||
[9]=mknew(ship_turret.new{ship_t=9, sprite=4}),
|
||||
[12]=mknew(ship_skirmisher.new{ship_t=12}),
|
||||
[13]=mknew(ship_skirmisher.new{ship_t=13, sprite=26}),
|
||||
[13]=mknew(ship_skirmisher.new{ship_t=13, sprite=26, path=diamond_bounce}),
|
||||
}
|
||||
end,
|
||||
}
|
||||
@@ -1454,8 +1723,9 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
|
||||
[12]=0,
|
||||
[13]=0,
|
||||
}
|
||||
local maxcol = 0
|
||||
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
|
||||
opt[i*4-4]=rnd()<v
|
||||
end
|
||||
@@ -1465,7 +1735,7 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
|
||||
mode = f&0x03
|
||||
if mode==2 then
|
||||
-- bits 0x0c: ship class
|
||||
local ship_t = f&0x0c
|
||||
local ship_t, col = f&0x0c, cx-ulc_cx
|
||||
-- bit 0x20: optional?
|
||||
if f&0x20 == 0 or opt[ship_t] then
|
||||
-- bit 0x10: alternate ship?
|
||||
@@ -1474,7 +1744,8 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
|
||||
-- and we allow alternates
|
||||
-- for this type of ship
|
||||
ship_t+=(uv>>ship_t&0x1)&((f&0x10)>>4)
|
||||
add(row, self.ship_bases[ship_t].new{col=cx-ulc_cx})
|
||||
add(row, self.ship_bases[ship_t].new{col=col})
|
||||
if (col > maxcol) maxcol = col
|
||||
end
|
||||
end
|
||||
cx += 1
|
||||
@@ -1494,6 +1765,13 @@ function flotilla:load(ulc_cx, ulc_cy, lvl)
|
||||
-- control mark bit 0x04: end of flotilla
|
||||
until f&0x04 > 0
|
||||
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)
|
||||
end
|
||||
|
||||
@@ -1573,13 +1851,13 @@ blip_fx = mknew{
|
||||
}
|
||||
|
||||
function blip_fx:move()
|
||||
if (self.cancel) return true
|
||||
if (self.cancel) return
|
||||
self.frames -= 1
|
||||
if self.frames < 0 then
|
||||
self.obj.fx_pal = nil
|
||||
return true
|
||||
return
|
||||
end
|
||||
return false
|
||||
return true
|
||||
end
|
||||
|
||||
function blip_fx:abort()
|
||||
@@ -1624,18 +1902,19 @@ spark_particle=mknew{}
|
||||
|
||||
function spark_particle:move()
|
||||
if (rnd(4) < 1) self.sidx += 1
|
||||
if (self.sidx > #self.sprs) return true
|
||||
if (self.sidx > #self.sprs) return
|
||||
self.x += self.dx
|
||||
self.y += self.dy
|
||||
self.dx -= mid(0.05,-0.05, self.dx)
|
||||
self.dy -= mid(0.05,-0.05, self.dy)
|
||||
return true
|
||||
end
|
||||
function spark_particle:draw()
|
||||
pset(self.x,self.y,self.sprs[self.sidx])
|
||||
end
|
||||
|
||||
function spark(sprs, x, y, dx, dy, odds, fg)
|
||||
if (sprs==nil or flr(rnd(odds) or (abs(dx) < 0.5 and abs(dy))) ~= 0) return
|
||||
if ((dx > -0.5 and dx < 0.5 and dy > -0.5 and dy < 0.5) or rnd(odds) >= 1) return
|
||||
local target = fg and intangibles_fg or intangibles_bg
|
||||
target[#target+1] = spark_particle.new{
|
||||
x = x + rnd(4) - 2,
|
||||
@@ -1654,7 +1933,7 @@ xp_gem = mknew(bullet_base.new{
|
||||
dy = 0.75,
|
||||
width=1, -- not used for spr but
|
||||
height=1,-- bullet_base uses it
|
||||
category = enemy_blt_cat,
|
||||
category = "ebullets",
|
||||
damage = 0,
|
||||
hurt = {
|
||||
x_off = -2,
|
||||
|
Reference in New Issue
Block a user