debug.lua 676 B

1234567891011121314151617181920212223
  1. local Debug = class()
  2. local g = love.graphics
  3. function Debug:init()
  4. self.depth = -1000000
  5. if ctx.view then ctx.view:register(self, 'gui') end
  6. end
  7. function Debug:gui()
  8. local x = math.floor(ctx.view:worldMouseX() / ctx.grid.size) * ctx.grid.size
  9. local y = math.floor(ctx.view:worldMouseY() / ctx.grid.size) * ctx.grid.size
  10. local message = x .. ',' .. y
  11. local w, h = love.graphics.getDimensions()
  12. g.setFont('pixel', 8)
  13. g.setColor(0, 0, 0)
  14. g.print(message, w - g.getFont():getWidth(message) + 1, h - g.getFont():getHeight() + 1)
  15. g.setColor(255, 255, 255)
  16. g.print(message, w - g.getFont():getWidth(message), h - g.getFont():getHeight())
  17. end
  18. return Debug