debug.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. local Debug = class()
  2. local g = love.graphics
  3. function Debug:draw()
  4. if env ~= 'release' then
  5. ctx.players:each(function(p)
  6. g.push()
  7. g.scale(ctx.view.scale)
  8. g.translate(-ctx.view.x, -ctx.view.y)
  9. if p.team == purple then g.setColor(190, 160, 220, p.alpha * 100)
  10. else g.setColor(240, 160, 140, p.alpha * 100) end
  11. p.shape:draw('fill')
  12. g.setLineWidth(2)
  13. if p.team == purple then g.setColor(190, 160, 220, p.alpha * 255)
  14. else g.setColor(240, 160, 140, p.alpha * 255) end
  15. p.shape:draw('line')
  16. g.setLineWidth(1)
  17. g.pop()
  18. end)
  19. end
  20. self.tStart = self.tStart or tick
  21. g.setColor(255, 255, 255, 100)
  22. local debug = love.timer.getFPS() .. 'fps'
  23. if ctx.net.server then
  24. debug = debug .. ', ' .. ctx.net.server:round_trip_time() .. 'ms'
  25. debug = debug .. ', ' .. math.round(ctx.net.host:total_sent_data() / 1000 / ((tick - self.tStart) * tickRate)) .. ' KB/s up'
  26. debug = debug .. ', ' .. math.round(ctx.net.host:total_received_data() / 1000 / ((tick - self.tStart) * tickRate)) .. ' KB/s dn'
  27. end
  28. g.setFont('aeromatics', ctx.hud.v * .02)
  29. g.print(debug, ctx.hud.u - g.getFont():getWidth(debug), ctx.hud.v - g.getFont():getHeight())
  30. end
  31. return Debug