From 85d28ae28bd9240b07f88b71fbefbcd18f086072 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Jun 2025 17:55:46 -0700 Subject: [PATCH] get rid of pships lots of things rely on exactly one primary ship now, so this was just overhead and wasted tokens / cspace. --- vacuum_gambit.p8 | 56 +++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 8d34d27..18357e2 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -169,8 +169,6 @@ function wipe_game() xpwhoosh = nil primary_ship = player.new() init_hpcols() - pships = linked_list.new() - pships:push_back(primary_ship) eships = linked_list.new() pbullets = linked_list.new() ebullets = linked_list.new() @@ -208,7 +206,8 @@ function ones(n) end 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() return _update60() end @@ -238,36 +237,24 @@ function updategame() end events:vore(new_events) 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) end - pships:strip( - function(ps) - local pbox, pded = hurtbox(ps), false - eships:strip( - function(es) - if (not collides(pbox, hurtbox(es))) return - pded = pded or ps:hitship(es) - return es:hitship(ps) - end - ) - return pded - end - ) - pships:strip( - 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 - ) + if not ps.dead then + ps:move() + local pbox = hurtbox(ps) + eships:strip(function(es) + if(not collides(pbox, hurtbox(es))) return + ps:hitship(es) + return es:hitship(ps) + end) + ebullets:strip(function(eb) + if (not collides(pbox, hurtbox(eb))) return + ps:hitbullet(eb) + return eb:hitship(ps) + end) + end -- many bullets and many enemy ships; -- 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 game_state = win 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 xpwhoosh = 0 else @@ -393,8 +380,8 @@ end function drawgame() clip(0,0,112,128) rectfill(0,0,112,128,0) - for slist in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do - slist:draw() + for drawable in all{intangibles_bg, pbullets, primary_ship, eships, ebullets, intangibles_fg} do + drawable:draw() end clip(0,0,128,128) drawhud() @@ -624,6 +611,7 @@ function ship_m:move() end function ship_m:draw() + if (self.dead) return if(self.fx_pal) pal(self.fx_pal) spr(self.sprite, self.x, self.y, self.size, self.size) pal()