Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. local width, xPos, yPos = include('config.lua')
  2. yPos = 0+8
  3.  
  4. local curPos = {
  5. { x = xPos, y = yPos-3 },
  6. { x = xPos-5, y = yPos-8 },
  7. { x = xPos+5, y= yPos-8 }
  8. }
  9.  
  10. local ultimateDirection = {
  11. [0]="N",
  12. [45]="NE",
  13. [90]="E",
  14. [135]="SE",
  15. [180]="S",
  16. [225]="SW",
  17. [270]="W",
  18. [315]="NW"
  19. }
  20.  
  21. local function drawCurrentPositionCursor()
  22. surface.SetDrawColor(255,255,255,255)
  23. draw.NoTexture()
  24. surface.DrawPoly(curPos)
  25. end
  26.  
  27. local function drawCompassLines()
  28. -- The angle increases towards the West, therefore we change the direction
  29. -- 0 = -0 & 180 = -180
  30. local angle = LocalPlayer():GetAngles().y*-1
  31.  
  32. local leftAngleEdge = (angle-90)
  33. local firstDrawn = math.ceil(leftAngleEdge/5)*5
  34. local rightAngleEdge = (angle+90)
  35. local lastDrawn = math.floor(rightAngleEdge/5)*5
  36.  
  37. surface.SetFont( "ChatFont" )
  38.  
  39. for drawn=firstDrawn, lastDrawn, 5 do
  40. -- The X coordinate, relative to the left side of the box
  41. local relativeX = width*(drawn-leftAngleEdge)/180
  42. -- The X coordinate relative to the screen
  43. local globalX = xPos - width/2+relativeX
  44.  
  45. local textPrint = drawn%360
  46. local boxW, boxH = 1, ScrH()*5/1080
  47. if (drawn%45 == 0) then
  48. surface.SetDrawColor( 255, 255, 255, 255*(1-((angle-drawn)/90)^2))
  49. surface.SetTextColor( 255, 255, 255, 255*(1-((angle-drawn)/90)^2))
  50. textPrint = ultimateDirection[textPrint]
  51. boxW, boxH = 2, boxH*3
  52. else
  53. surface.SetDrawColor( 200, 200, 200, 128*(1-((angle-drawn)/90)^2))
  54. surface.SetTextColor( 200, 200, 200, 128*(1-((angle-drawn)/90)^2))
  55. if (drawn%15 == 0) then
  56. boxH = boxH*2
  57. end
  58. end
  59.  
  60. if(drawn%15 == 0) then
  61. local w,h = surface.GetTextSize(textPrint)
  62. surface.SetTextPos( globalX-(w/2), yPos+boxH)
  63. surface.DrawText(textPrint)
  64. end
  65. surface.DrawRect(globalX-boxW/2, yPos, boxW, boxH)
  66. end
  67. end
  68.  
  69. hook.Add( "HUDPaint", "update_compass", function()
  70. draw.RoundedBox( 5, xPos-width/2-10, yPos-11, width+20, 45, Color(0,0,0,200) )
  71. drawCompassLines()
  72. drawCurrentPositionCursor()
  73. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement