Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local width, xPos, yPos = include('config.lua')
- yPos = 0+8
- local curPos = {
- { x = xPos, y = yPos-3 },
- { x = xPos-5, y = yPos-8 },
- { x = xPos+5, y= yPos-8 }
- }
- local ultimateDirection = {
- [0]="N",
- [45]="NE",
- [90]="E",
- [135]="SE",
- [180]="S",
- [225]="SW",
- [270]="W",
- [315]="NW"
- }
- local function drawCurrentPositionCursor()
- surface.SetDrawColor(255,255,255,255)
- draw.NoTexture()
- surface.DrawPoly(curPos)
- end
- local function drawCompassLines()
- -- The angle increases towards the West, therefore we change the direction
- -- 0 = -0 & 180 = -180
- local angle = LocalPlayer():GetAngles().y*-1
- local leftAngleEdge = (angle-90)
- local firstDrawn = math.ceil(leftAngleEdge/5)*5
- local rightAngleEdge = (angle+90)
- local lastDrawn = math.floor(rightAngleEdge/5)*5
- surface.SetFont( "ChatFont" )
- for drawn=firstDrawn, lastDrawn, 5 do
- -- The X coordinate, relative to the left side of the box
- local relativeX = width*(drawn-leftAngleEdge)/180
- -- The X coordinate relative to the screen
- local globalX = xPos - width/2+relativeX
- local textPrint = drawn%360
- local boxW, boxH = 1, ScrH()*5/1080
- if (drawn%45 == 0) then
- surface.SetDrawColor( 255, 255, 255, 255*(1-((angle-drawn)/90)^2))
- surface.SetTextColor( 255, 255, 255, 255*(1-((angle-drawn)/90)^2))
- textPrint = ultimateDirection[textPrint]
- boxW, boxH = 2, boxH*3
- else
- surface.SetDrawColor( 200, 200, 200, 128*(1-((angle-drawn)/90)^2))
- surface.SetTextColor( 200, 200, 200, 128*(1-((angle-drawn)/90)^2))
- if (drawn%15 == 0) then
- boxH = boxH*2
- end
- end
- if(drawn%15 == 0) then
- local w,h = surface.GetTextSize(textPrint)
- surface.SetTextPos( globalX-(w/2), yPos+boxH)
- surface.DrawText(textPrint)
- end
- surface.DrawRect(globalX-boxW/2, yPos, boxW, boxH)
- end
- end
- hook.Add( "HUDPaint", "update_compass", function()
- draw.RoundedBox( 5, xPos-width/2-10, yPos-11, width+20, 45, Color(0,0,0,200) )
- drawCompassLines()
- drawCurrentPositionCursor()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement