summaryrefslogtreecommitdiff
path: root/bump/bump_debug.lua
blob: 308608f95ea245c0bb288bf37d2717f084eea871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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