CapsAdmin

Untitled

Nov 19th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.83 KB | None | 0 0
  1. local DEMO = {}
  2.  
  3. DEMO.Author = "Mathias"
  4. DEMO.Title = "restart"
  5.  
  6. local CONFIG = {}
  7.  
  8. CONFIG.TargetTime   = 0
  9. CONFIG.Counting     = falses
  10. CONFIG.Warning      = ""
  11. CONFIG.PopupText    = ""
  12. CONFIG.PopupPos     = {0,0}
  13. CONFIG.LastPopup    = CurTime()
  14. CONFIG.Popups       = { "HURRY!", "FASTER!", "YOU WON'T MAKE IT!", "QUICKLY!", "GOD YOU'RE SLOW!", "DID YOU GET EVERYTHING?!", "ARE YOU SURE THAT'S EVERYTHING?!", "OH GOD!", "OH MAN!", "YOU FORGOT SOMETHING!", "SAVE SAVE SAVE" }
  15. CONFIG.NextStress   = CurTime()
  16. CONFIG.LastNumber   = CurTime()
  17.  
  18. surface.CreateFont(
  19.     "aowl_restart",
  20.     {
  21.         font        = "Roboto Bk",
  22.         size        = 40,
  23.         weight      = 1000,
  24.     }
  25. )
  26.  
  27. function DEMO:OnDraw(W, H, m)
  28.     surface.SetDrawColor(255, 50, 50, 100 + (math.sin(CurTime() * 3) * 80))
  29.     surface.DrawRect(0, 0, W, H)
  30.  
  31.     surface.SetFont("aowl_restart")
  32.     surface.SetTextColor(Color(50, 50, 50, 255))
  33.     local w = surface.GetTextSize(CONFIG.Warning)
  34.     w=w or 56
  35.     surface.SetTextPos((W / 2) - w / 2, 200)
  36.     surface.DrawText(CONFIG.Warning)
  37.  
  38.     surface.SetDrawColor(Color(0,255,0,255))
  39.     surface.DrawRect((W - w)/2, 175, w * math.max(0, (CONFIG.TargetTime-CurTime())/(CONFIG.TargetTime-CONFIG.StartedCount) ), 20)
  40.     surface.SetDrawColor(color_black)
  41.     surface.DrawOutlinedRect((W - w)/2, 175, w, 20)
  42.  
  43.     local Count = tostring(CONFIG.TargetTime - CurTime()):sub(1, 6)
  44.     w = surface.GetTextSize(Count)
  45.  
  46.     surface.SetTextPos((W / 2) - w / 2, 240)
  47.     surface.DrawText(Count)
  48.  
  49.     surface.SetTextColor(255, 255, 255, 255)
  50.     if(CurTime() - CONFIG.LastPopup > 0.5) then
  51.         CONFIG.PopupText = { CONFIG.Popups[math.random(1,#CONFIG.Popups)], CONFIG.Popups[math.random(1,#CONFIG.Popups)], CONFIG.Popups[math.random(1,#CONFIG.Popups)] }
  52.         CONFIG.PopupPos = {{math.random(1, W - 150), math.random(1, H - 10) },{math.random(1, W - 150), math.random(1, H - 10) },{math.random(1, W - 150), math.random(1, H - 10) }}
  53.         CONFIG.LastPopup = CurTime()
  54.     end
  55.  
  56.     if(CurTime() > CONFIG.NextStress) then
  57.         CONFIG.NextStress = CurTime() + math.random(1, 2)
  58.     end
  59.  
  60.     for i = 1, 3 do
  61.        
  62.         local text = CONFIG.PopupText[i]
  63.         local x,y = CONFIG.PopupPos[i][1], CONFIG.PopupPos[i][2]
  64.        
  65.         math.randomseed(i + x + y)
  66.        
  67.         local textWidth, textHeight = surface.GetTextSize(Count)
  68.        
  69.         local recenter = Matrix()
  70.         recenter:Translate(Vector(-textWidth * 0.5, -textHeight * 0.5, 0))
  71.        
  72.         local rotation = Matrix()
  73.         rotation:Rotate(Angle (0, math.Rand(-45, 45), 0))
  74.        
  75.         local uncenter = Matrix()
  76.         uncenter:Translate(Vector(x, y, 0))
  77.        
  78.         local mat = uncenter * rotation * recenter
  79.        
  80.         cam.PushModelMatrix(mat)
  81.             surface.SetTextPos(0,0)
  82.             surface.DrawText(text)
  83.         cam.PopModelMatrix()
  84.     end
  85. end
  86.  
  87. function DEMO:OnStart()
  88.     CONFIG.StartedCount = CurTime()
  89.     CONFIG.TargetTime = CurTime() + 15
  90.     CONFIG.Counting = true
  91.    
  92.     CONFIG.Warning = "THIS IS A DEMO, SAVE YOUR PROPS AND HIDE THE CHILDREN!"
  93. end
  94.  
  95. demoman.demos = {}
  96. demoman.AddDemo(DEMO)
Advertisement
Add Comment
Please, Sign In to add comment