CapsAdmin

Untitled

Jan 14th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 KB | None | 0 0
  1. local ENT = this
  2. local size = 256
  3.  
  4. local count = 100
  5. local sand = {}
  6.  
  7. for i=1, count do
  8.     sand[i] =
  9.     {
  10.         pos = Vector(size*0.5,size*0.5, 0),
  11.         vel = vector_origin,
  12.     }
  13. end
  14.  
  15. local function drawpixel(i)
  16.     surface.SetTextPos(sand[i].pos.x, sand[i].pos.y)
  17.     surface.DrawText(string.char(math.random(32, 128)))
  18.     --[[ace.DrawLine(
  19.         sand[i].pos.x,
  20.         sand[i].pos.y,
  21.  
  22.         sand[i].pos.x+1,
  23.         sand[i].pos.y+1
  24.         --sand[math.min(i+1, count)].pos.x,
  25.         --sand[math.min(i+1, count)].pos.y
  26.     )]]
  27. end
  28.  
  29. local new
  30. local function localtoworld(vec, ang)
  31.     new = WorldToLocal(vec, Angle(0), Vector(0), ang)
  32.     new:Rotate(Angle(0,-90,0))
  33.     return new
  34. end
  35. local vel
  36. local function DrawScreen()
  37.     surface.SetDrawColor(0,0,0,120)
  38.     surface.DrawRect(0,0,size,size)
  39.  
  40.     surface.SetDrawColor(200,230,255,255)
  41.     surface.SetTextColor( 200, 230, 255, 255 )
  42.     surface.SetFont("DefaultFixedOutline")
  43.  
  44.     local newvel = localtoworld(ENT:GetVelocity(), ENT:GetAngles()) * 0.5
  45.  
  46.     for i, part in pairs(sand) do
  47.  
  48.         vel = vel + newvel
  49.         vel = vel + VectorRand() * 2
  50.  
  51.         sand[i].pos = sand[i].pos + (sand[i].vel * FrameTime())
  52.  
  53.         sand[i].vel = vel + (sand[i].vel * 0.99)
  54.  
  55.         if sand[i].pos.x < 0 then
  56.             sand[i].pos.x = 1
  57.             sand[i].vel.x = -sand[i].vel.x * math.random()
  58.         end
  59.         if sand[i].pos.x > size then
  60.             sand[i].pos.x = size-1
  61.             sand[i].vel.x = -sand[i].vel.x * math.random()
  62.         end
  63.         if sand[i].pos.y < 0 then
  64.             sand[i].pos.y = 1
  65.             sand[i].vel.y = -sand[i].vel.y * math.random()
  66.         end
  67.         if sand[i].pos.y > size then
  68.             sand[i].pos.y = size-1
  69.             sand[i].vel.y = -sand[i].vel.y * math.random()
  70.         end
  71.  
  72.  
  73.         drawpixel(i)
  74.     end
  75. end
  76.  
  77. local new = GetRenderTarget("test_rt", size, size, true)
  78.  
  79. local function main()
  80.     local old, w, h = render.GetRenderTarget(), ScrW(), ScrH()
  81.  
  82.     render.SetRenderTarget(new)
  83.          -- render.Clear(68,112,146, 50, false)
  84.         render.SetViewPort(0, 0, size, size)
  85.             cam.Start2D()
  86.                 DrawScreen()
  87.             cam.End2D()
  88.         render.SetViewPort(0, 0, w, h)
  89.     render.SetRenderTarget(old)
  90. end
  91.  
  92.  
  93. local mat = CreateMaterial("test_rt_mat", "VertexLitGeneric",
  94.     {
  95.         ["$basetexture"] = "test_rt",
  96.     }
  97. )
  98.  
  99. ENT:SetModelScale(Vector())
  100.  
  101. function ENT:RenderOverride()
  102.     main()
  103.  
  104.     SetMaterialOverride(mat)
  105.         self:DrawModel()
  106.     SetMaterialOverride()
  107. end
Advertisement
Add Comment
Please, Sign In to add comment