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