drawgame via strip, remove bury_the_dead

This commit is contained in:
Kistaro Windrider 2023-09-29 09:55:43 -07:00
parent 1ba869b644
commit 3b8e86d0e7
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -93,6 +93,21 @@ function linked_list:strip(f)
return p return p
end end
-- optimized special case -
-- could be done with strip but
-- this avoids extra function
-- calls and comparisions since
-- draw isn't allowed to kill
-- the item
function linked_list:draw()
local n = self.next
while n do
n:draw()
n = n.next
end
end
function linked_list:pop_front() function linked_list:pop_front()
local ret = self.next local ret = self.next
if (not ret) return if (not ret) return
@ -101,15 +116,6 @@ function linked_list:pop_front()
return ret return ret
end end
function linked_list:fix_tail()
local p, n = self, self.next
while n do
p = n
n = n.next
end
self.tail = p
end
function _init() function _init()
init_bullet_mt() init_bullet_mt()
init_powerup_mt() init_powerup_mt()
@ -220,7 +226,11 @@ function updategame()
if pb:hitship(es) then if pb:hitship(es) then
pbullet_collider:hide(pb) pbullet_collider:hide(pb)
pb.prev.next = pb.next pb.prev.next = pb.next
if (pb.next) pb.next.prev = pb.prev if pb.next then
pb.next.prev = pb.prev
else
pbullets.tail = pb.prev
end
end end
if (es:hitbullet(pb)) return true if (es:hitbullet(pb)) return true
end end
@ -237,8 +247,6 @@ function updategame()
end end
end end
-- XXX BOOKMARK XXX
function _draw() function _draw()
drawgame() drawgame()
draw_debug() draw_debug()
@ -301,10 +309,8 @@ end
function drawgame() function drawgame()
cls() cls()
clip(0,0,112,128) clip(0,0,112,128)
for tbl in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do for slist in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do
for x in all(tbl) do slist:draw()
x:draw()
end
end end
clip(0,0,128,128) clip(0,0,128,128)
drawhud() drawhud()
@ -405,30 +411,11 @@ function grab_p1_butts()
} }
end end
function bury_the_dead(tbl, dead)
if (#dead == 0) return
local tail = dead[1]
local head = tail + 1
local deaddex = 2
while head <= #tbl do
while deaddex <= #dead and head == dead[deaddex] do
deaddex += 1
head += 1
end
if (head > #tbl) break
tbl[tail] = tbl[head]
head += 1
tail += 1
end
for i=1,(head-tail) do
deli(tbl)
end
end
-->8 -->8
--ships, including player --ships, including player
-- XXX BOOKMARK XXX
function init_ship_mt() function init_ship_mt()
setmetatable(player, ship_t) setmetatable(player, ship_t)
setmetatable(frownie, ship_t) setmetatable(frownie, ship_t)