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
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()
local ret = self.next
if (not ret) return
@ -101,15 +116,6 @@ function linked_list:pop_front()
return ret
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()
init_bullet_mt()
init_powerup_mt()
@ -220,7 +226,11 @@ function updategame()
if pb:hitship(es) then
pbullet_collider:hide(pb)
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
if (es:hitbullet(pb)) return true
end
@ -237,8 +247,6 @@ function updategame()
end
end
-- XXX BOOKMARK XXX
function _draw()
drawgame()
draw_debug()
@ -301,10 +309,8 @@ end
function drawgame()
cls()
clip(0,0,112,128)
for tbl in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do
for x in all(tbl) do
x:draw()
end
for slist in all{intangibles_bg, pbullets, pships, eships, ebullets, intangibles_fg} do
slist:draw()
end
clip(0,0,128,128)
drawhud()
@ -405,30 +411,11 @@ function grab_p1_butts()
}
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
--ships, including player
-- XXX BOOKMARK XXX
function init_ship_mt()
setmetatable(player, ship_t)
setmetatable(frownie, ship_t)