Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DEMO = {}
- DEMO.Author = "Mathias"
- DEMO.Title = "restart"
- local CONFIG = {}
- CONFIG.TargetTime = 0
- CONFIG.Counting = falses
- CONFIG.Warning = ""
- CONFIG.PopupText = ""
- CONFIG.PopupPos = {0,0}
- CONFIG.LastPopup = CurTime()
- 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" }
- CONFIG.NextStress = CurTime()
- CONFIG.LastNumber = CurTime()
- surface.CreateFont(
- "aowl_restart",
- {
- font = "Roboto Bk",
- size = 40,
- weight = 1000,
- }
- )
- function DEMO:OnDraw(W, H, m)
- surface.SetDrawColor(255, 50, 50, 100 + (math.sin(CurTime() * 3) * 80))
- surface.DrawRect(0, 0, W, H)
- surface.SetFont("aowl_restart")
- surface.SetTextColor(Color(50, 50, 50, 255))
- local w = surface.GetTextSize(CONFIG.Warning)
- w=w or 56
- surface.SetTextPos((W / 2) - w / 2, 200)
- surface.DrawText(CONFIG.Warning)
- surface.SetDrawColor(Color(0,255,0,255))
- surface.DrawRect((W - w)/2, 175, w * math.max(0, (CONFIG.TargetTime-CurTime())/(CONFIG.TargetTime-CONFIG.StartedCount) ), 20)
- surface.SetDrawColor(color_black)
- surface.DrawOutlinedRect((W - w)/2, 175, w, 20)
- local Count = tostring(CONFIG.TargetTime - CurTime()):sub(1, 6)
- w = surface.GetTextSize(Count)
- surface.SetTextPos((W / 2) - w / 2, 240)
- surface.DrawText(Count)
- surface.SetTextColor(255, 255, 255, 255)
- if(CurTime() - CONFIG.LastPopup > 0.5) then
- CONFIG.PopupText = { CONFIG.Popups[math.random(1,#CONFIG.Popups)], CONFIG.Popups[math.random(1,#CONFIG.Popups)], CONFIG.Popups[math.random(1,#CONFIG.Popups)] }
- 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) }}
- CONFIG.LastPopup = CurTime()
- end
- if(CurTime() > CONFIG.NextStress) then
- CONFIG.NextStress = CurTime() + math.random(1, 2)
- end
- for i = 1, 3 do
- local text = CONFIG.PopupText[i]
- local x,y = CONFIG.PopupPos[i][1], CONFIG.PopupPos[i][2]
- math.randomseed(i + x + y)
- local textWidth, textHeight = surface.GetTextSize(Count)
- local recenter = Matrix()
- recenter:Translate(Vector(-textWidth * 0.5, -textHeight * 0.5, 0))
- local rotation = Matrix()
- rotation:Rotate(Angle (0, math.Rand(-45, 45), 0))
- local uncenter = Matrix()
- uncenter:Translate(Vector(x, y, 0))
- local mat = uncenter * rotation * recenter
- cam.PushModelMatrix(mat)
- surface.SetTextPos(0,0)
- surface.DrawText(text)
- cam.PopModelMatrix()
- end
- end
- function DEMO:OnStart()
- CONFIG.StartedCount = CurTime()
- CONFIG.TargetTime = CurTime() + 15
- CONFIG.Counting = true
- CONFIG.Warning = "THIS IS A DEMO, SAVE YOUR PROPS AND HIDE THE CHILDREN!"
- end
- demoman.demos = {}
- demoman.AddDemo(DEMO)
Advertisement
Add Comment
Please, Sign In to add comment