Compare commits
6 Commits
904fbe6b2e
...
silly-shot
Author | SHA1 | Date | |
---|---|---|---|
7e4833d567
|
|||
c752e8e1e3
|
|||
507f06fb8c
|
|||
14849101dd
|
|||
2cd7c64dd9
|
|||
2d5d392df0
|
108
vacuum_gambit.p8
108
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()
|
||||
@ -196,11 +196,11 @@ function updategame()
|
||||
current_wave = flotilla.new()
|
||||
current_wave:load(rnd() > 0.5 and 7 or 0, 0, min(ones(waves_complete)\2, 4))
|
||||
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 +213,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
|
||||
@ -535,10 +536,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 +547,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 +556,7 @@ function ship_m:move()
|
||||
self.xmomentum = xm
|
||||
self.ymomentum = ym
|
||||
|
||||
return false
|
||||
return true
|
||||
end
|
||||
|
||||
function ship_m:draw()
|
||||
@ -617,14 +618,6 @@ 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 +630,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 +767,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 +777,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 +847,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 +906,7 @@ blast = mknew(bullet_base.new{
|
||||
end)
|
||||
end
|
||||
end,
|
||||
category=player_blt_cat
|
||||
category="pbullets"
|
||||
})
|
||||
|
||||
blast_gun = mknew(gun_base.new{
|
||||
@ -952,14 +945,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 +999,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{
|
||||
@ -1029,7 +1022,7 @@ machine_gun_e = mknew(vulcan_gun_e.new{
|
||||
icon = 38,
|
||||
clip_size = 12,
|
||||
clip_interval = 0x0.005a,
|
||||
shots = {{{0, 2}}, {{0, -2}}}
|
||||
shots = {{{0.0625, 2}}, {{-0.0625, -2}}}
|
||||
})
|
||||
|
||||
vulcan_gun_p = mknew(vulcan_gun_e.new{
|
||||
@ -1071,8 +1064,8 @@ player = mknew(ship_m.new{
|
||||
boss = true, -- dramatic special effects
|
||||
|
||||
-- health
|
||||
hp = 3, -- current health, non-regenerating
|
||||
maxhp = 3, -- player only; other ships never heal
|
||||
hp = 1024, -- current health, non-regenerating
|
||||
maxhp = 1024, -- player only; other ships never heal
|
||||
shield = 2, -- regenerates
|
||||
maxshield = 2,
|
||||
|
||||
@ -1350,11 +1343,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{
|
||||
@ -1573,13 +1566,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 +1617,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 +1648,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