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:
parent
c514c61b3a
commit
85d28ae28b
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user