diff options
author | chai <chaifix@163.com> | 2018-09-02 19:49:27 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-02 19:49:27 +0800 |
commit | cf608a2af7106f9901bc0632c96594d2c938b416 (patch) | |
tree | ad18a2edd0c8e1bc26e668d321d24af34ff3ac25 /bump/bump_debug.lua | |
parent | 340861d2a5e4391e2f1671663f6812f1228a4c78 (diff) |
*update
Diffstat (limited to 'bump/bump_debug.lua')
-rw-r--r-- | bump/bump_debug.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bump/bump_debug.lua b/bump/bump_debug.lua new file mode 100644 index 0000000..308608f --- /dev/null +++ b/bump/bump_debug.lua @@ -0,0 +1,31 @@ + +local bump = require 'bump' + +local bump_debug = {} + +local function getCellRect(world, cx,cy) + local cellSize = world.cellSize + local l,t = world:toWorld(cx,cy) + return l,t,cellSize,cellSize +end + +function bump_debug.draw(world) + local cellSize = world.cellSize + -- local font = love.graphics.getFont() + local fontHeight = 20 + local topOffset = (cellSize - fontHeight) / 2 + for cy, row in pairs(world.rows) do + for cx, cell in pairs(row) do + local l,t,w,h = getCellRect(world, cx,cy) + local intensity = cell.itemCount * 12 + 16 + jin.graphics.setColor(255,255,255,intensity) + jin.graphics.rect('fill', l,t,w,h) + jin.graphics.setColor(255,255,255, 64) + -- jin.graphics.printf(cell.itemCount, l, t+topOffset, cellSize, 'center') + jin.graphics.setColor(255,255,255,10) + jin.graphics.rect('line', l,t,w,h) + end + end +end + +return bump_debug |