Compare commits
5 Commits
da8a5b9589
...
a4bf3f616a
Author | SHA1 | Date | |
---|---|---|---|
a4bf3f616a | |||
8fb54ede26 | |||
cb65a188a8 | |||
7c29c329b7 | |||
f67c2da37f |
@ -9,8 +9,6 @@ game = 1
|
||||
win = 2
|
||||
lose = 3
|
||||
|
||||
debug = {}
|
||||
|
||||
function usplit(str)
|
||||
return unpack(split(str))
|
||||
end
|
||||
@ -47,7 +45,9 @@ function mknew(tt, more)
|
||||
end
|
||||
end
|
||||
|
||||
linked_list = {}
|
||||
-- intrusive singly-linked list.
|
||||
-- cannot be nested!
|
||||
linked_list = {is_linked_list=true}
|
||||
mknew(linked_list, function(x)
|
||||
x.next=nil
|
||||
x.tail=x
|
||||
@ -251,7 +251,6 @@ end
|
||||
|
||||
function _draw()
|
||||
drawgame()
|
||||
draw_debug()
|
||||
if (state == game) fadelvl = -45
|
||||
if (state == win) dropshadow("win",50,61,11)
|
||||
if (state == lose) dropshadow("fail",48,61,8)
|
||||
@ -291,21 +290,44 @@ function fadescreen()
|
||||
end
|
||||
end
|
||||
|
||||
function draw_debug()
|
||||
cursor(0,0,7)
|
||||
-- uncomment the followingh
|
||||
-- to display object counts
|
||||
--[[
|
||||
print("es "..tostr(#eships))
|
||||
print("eb "..tostr(#ebullets))
|
||||
print("pb "..tostr(#pbullets))
|
||||
print("ib "..tostr(#intangibles_bg))
|
||||
print("if "..tostr(#intangibles_fg))
|
||||
print("v "..tostr(#events))
|
||||
]]
|
||||
if (#debug==0) return
|
||||
foreach(debug,print)
|
||||
debug={}
|
||||
-- puke emits a verbose string
|
||||
-- describing item, indented to
|
||||
-- the specified depth (0 by
|
||||
-- default). used for table
|
||||
-- debugging. table-type keys
|
||||
-- are not legible here
|
||||
function puke(item, indent, seen, hidekey)
|
||||
if (type(item) ~= "table") return tostr(item)
|
||||
|
||||
seen = seen or {}
|
||||
if (seen[item]) return "<<...>>"
|
||||
seen[item] = true
|
||||
|
||||
indent = indent or 0
|
||||
local pfx = "\n"
|
||||
for _=1,indent do
|
||||
pfx ..= " "
|
||||
end
|
||||
|
||||
if item.is_linked_list then
|
||||
local ret,n,xpfx = "linked_list <",0,pfx.." "
|
||||
item:strip(function(x)
|
||||
n += 1
|
||||
ret ..= xpfx..tostr(n)..": "..puke(x, indent+1, seen, "next")
|
||||
end)
|
||||
return ret..pfx..">"
|
||||
end
|
||||
|
||||
local ret = "{"
|
||||
for k, v in pairs(item) do
|
||||
if (k ~= hidekey) ret ..= pfx..tostr(k)..": "..puke(v, indent+1, seen)
|
||||
end
|
||||
return ret..pfx.."}"
|
||||
end
|
||||
|
||||
-- convenience for debugging
|
||||
function puketh(item)
|
||||
printh(puke(item))
|
||||
end
|
||||
|
||||
function drawgame()
|
||||
|
Loading…
Reference in New Issue
Block a user