Advertisement
C0BRA

Crosshair

Jun 9th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. Plugin.Crosshair = function()
  2.     local start = qq.Setting(Plugin, "crosshair_space")
  3.     local size = qq.Setting(Plugin, "crosshair_size")
  4.     local rps = qq.Setting(Plugin, "crosshair_rps")
  5.     local segments = qq.Setting(Plugin, "crosshair_segments")
  6.    
  7.     surface.SetDrawColor(qq.Setting(Plugin, "crosshair_color"))
  8.    
  9.     local time = -RealTime() * (math.pi * 2) * rps
  10.     local segmentsize = (math.pi * 2) / segments
  11.    
  12.     for i = 0, segments - 1 do
  13.         local timeoffset = segmentsize * i
  14.        
  15.         Plugin.DrawCrossSegment(time + timeoffset, size, start)
  16.     end
  17.    
  18.     local x,y = qq.ScreenSize.x / 2, qq.ScreenSize.y / 2
  19.     surface.DrawRect(x,y,1,1)
  20. end
  21.  
  22. Plugin.DrawCrossSegment = function(time, size, start) // Just a conveniance function
  23.     local x,y = qq.ScreenSize.x / 2, qq.ScreenSize.y / 2
  24.    
  25.     local sin = math.sin(time)
  26.     local cos = math.cos(time)
  27.    
  28.     local startx = sin * start
  29.     local endx = sin * (start + size)
  30.    
  31.     local starty = cos * start
  32.     local endy = cos * (start + size)
  33.    
  34.     surface.DrawLine(x + startx, y + starty, x + endx, y + endy)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement