get rid of pships

lots of things rely on exactly one primary ship now, so this was just
overhead and wasted tokens / cspace.
This commit is contained in:
Kistaro Windrider 2025-06-01 17:55:46 -07:00
parent c514c61b3a
commit 85d28ae28b
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -169,8 +169,6 @@ function wipe_game()
xpwhoosh = nil xpwhoosh = nil
primary_ship = player.new() primary_ship = player.new()
init_hpcols() init_hpcols()
pships = linked_list.new()
pships:push_back(primary_ship)
eships = linked_list.new() eships = linked_list.new()
pbullets = linked_list.new() pbullets = linked_list.new()
ebullets = linked_list.new() ebullets = linked_list.new()
@ -208,7 +206,8 @@ function ones(n)
end end
function updategame() function updategame()
if (primary_ship.xp >= primary_ship.xptarget) and (gframe - primary_ship.last_xp_frame > 0x0.000f) and (not primary_ship.dead) then local ps = primary_ship
if (ps.xp >= ps.xptarget) and (gframe - ps.last_xp_frame > 0x0.000f) and (not ps.dead) then
mode = rearm_mode.new() mode = rearm_mode.new()
return _update60() return _update60()
end end
@ -238,36 +237,24 @@ function updategame()
end end
events:vore(new_events) events:vore(new_events)
events:strip(call_move) events:strip(call_move)
for _, lst in ipairs{intangibles_bg, pships, eships, pbullets, ebullets} do for _, lst in ipairs{intangibles_bg, eships, pbullets, ebullets} do
lst:strip(call_move) lst:strip(call_move)
end end
pships:strip( if not ps.dead then
function(ps) ps:move()
local pbox, pded = hurtbox(ps), false local pbox = hurtbox(ps)
eships:strip( eships:strip(function(es)
function(es) if(not collides(pbox, hurtbox(es))) return
if (not collides(pbox, hurtbox(es))) return ps:hitship(es)
pded = pded or ps:hitship(es) return es:hitship(ps)
return es:hitship(ps) end)
end ebullets:strip(function(eb)
) if (not collides(pbox, hurtbox(eb))) return
return pded ps:hitbullet(eb)
end return eb:hitship(ps)
) end)
pships:strip( end
function(ps)
local pbox, pded = hurtbox(ps), false
ebullets:strip(
function(eb)
if (not collides(pbox, hurtbox(eb))) return
pded = pded or ps:hitbullet(eb)
return eb:hitship(ps)
end
)
return pded
end
)
-- many bullets and many enemy ships; -- many bullets and many enemy ships;
-- use bucket collider for efficiency -- use bucket collider for efficiency
@ -302,9 +289,9 @@ function updategame()
if waves_complete == 32767 and not eships.next and not ebullets.next and not events.next then if waves_complete == 32767 and not eships.next and not ebullets.next and not events.next then
game_state = win game_state = win
end end
if (not pships.next) game_state = lose if (ps.dead) game_state = lose
if primary_ship.xp >= primary_ship.xptarget then if ps.xp >= ps.xptarget then
if not xpwhoosh then if not xpwhoosh then
xpwhoosh = 0 xpwhoosh = 0
else else
@ -393,8 +380,8 @@ end
function drawgame() function drawgame()
clip(0,0,112,128) clip(0,0,112,128)
rectfill(0,0,112,128,0) rectfill(0,0,112,128,0)
for slist in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do for drawable in all{intangibles_bg, pbullets, primary_ship, eships, ebullets, intangibles_fg} do
slist:draw() drawable:draw()
end end
clip(0,0,128,128) clip(0,0,128,128)
drawhud() drawhud()
@ -624,6 +611,7 @@ function ship_m:move()
end end
function ship_m:draw() function ship_m:draw()
if (self.dead) return
if(self.fx_pal) pal(self.fx_pal) if(self.fx_pal) pal(self.fx_pal)
spr(self.sprite, self.x, self.y, self.size, self.size) spr(self.sprite, self.x, self.y, self.size, self.size)
pal() pal()