Compare commits
No commits in common. "a4bf3f616a4a32f3d684f89f7462ab812f7914c5" and "da8a5b9589775e61d73c3336bc5b171ec4a34328" have entirely different histories.
a4bf3f616a
...
da8a5b9589
@ -9,6 +9,8 @@ game = 1
|
||||
win = 2
|
||||
lose = 3
|
||||
|
||||
debug = {}
|
||||
|
||||
function usplit(str)
|
||||
return unpack(split(str))
|
||||
end
|
||||
@ -45,9 +47,7 @@ function mknew(tt, more)
|
||||
end
|
||||
end
|
||||
|
||||
-- intrusive singly-linked list.
|
||||
-- cannot be nested!
|
||||
linked_list = {is_linked_list=true}
|
||||
linked_list = {}
|
||||
mknew(linked_list, function(x)
|
||||
x.next=nil
|
||||
x.tail=x
|
||||
@ -251,6 +251,7 @@ 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)
|
||||
@ -290,44 +291,21 @@ function fadescreen()
|
||||
end
|
||||
end
|
||||
|
||||
-- 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))
|
||||
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={}
|
||||
end
|
||||
|
||||
function drawgame()
|
||||
|
Loading…
Reference in New Issue
Block a user