players.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. local Players = class()
  2. local g = love.graphics
  3. function Players:draw()
  4. g.setFont('pixel', 8)
  5. ctx.players:each(function(p)
  6. if not p.ded then
  7. local vx, vy = math.lerp(ctx.view.prevx, ctx.view.x, tickDelta / tickRate), math.lerp(ctx.view.prevy, ctx.view.y, tickDelta / tickRate)
  8. local px, py = p.drawX, p.drawY
  9. local alpha = p.alpha * (1 - (p.cloak / (p.team == ctx.players:get(ctx.id).team and 2 or 1)))
  10. g.setColor(0, 0, 0, 150 * alpha)
  11. g.printCenter(p.username, (px - vx) * ctx.view.scale + 1, ((py - vy) * ctx.view.scale) - 60 + 1)
  12. if p.team == purple then g.setColor(190, 160, 220, alpha * 255)
  13. elseif p.team == orange then g.setColor(240, 160, 140, alpha * 255) end
  14. g.printCenter(p.username, (px - vx) * ctx.view.scale, ((py - vy) * ctx.view.scale) - 60)
  15. local x0 = ((px - vx) * ctx.view.scale) - 40
  16. local y0 = ((py - vy) * ctx.view.scale) - 50
  17. local healthWidth, shieldWidth = (p.health / p.maxHealth) * 80, (p.shield / p.maxHealth) * 80
  18. local totalWidth = math.max(healthWidth + shieldWidth, 80)
  19. g.setColor(0, 0, 0, 128 * alpha) -- Dark background
  20. g.rectangle('fill', x0, y0, totalWidth, 10)
  21. g.setColor(200, 0, 0, 128 * alpha) -- Health
  22. g.rectangle('fill', x0 + .5, y0 + .5, healthWidth - 1, 10 - 1)
  23. g.setColor(220, 220, 220, 128 * alpha) -- Shield
  24. g.rectangle('fill', x0 + healthWidth, y0, shieldWidth, 10)
  25. g.setColor(150, 0, 0, 255 * alpha) -- Frame
  26. g.rectangle('line', x0, y0, totalWidth, 10)
  27. end
  28. end)
  29. local p = ctx.players:get(ctx.id)
  30. if p then
  31. for i = 1, 5 do
  32. f.exe(p.slots[i].gui, p.slots[i], p)
  33. end
  34. end
  35. end
  36. return Players