Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ENT = this
- local size = 256
- local count = 100
- local sand = {}
- for i=1, count do
- sand[i] =
- {
- pos = Vector(size*0.5,size*0.5, 0),
- vel = vector_origin,
- }
- end
- local function drawpixel(i)
- surface.SetTextPos(sand[i].pos.x, sand[i].pos.y)
- surface.DrawText(string.char(math.random(32, 128)))
- --[[ace.DrawLine(
- sand[i].pos.x,
- sand[i].pos.y,
- sand[i].pos.x+1,
- sand[i].pos.y+1
- --sand[math.min(i+1, count)].pos.x,
- --sand[math.min(i+1, count)].pos.y
- )]]
- end
- local new
- local function localtoworld(vec, ang)
- new = WorldToLocal(vec, Angle(0), Vector(0), ang)
- new:Rotate(Angle(0,-90,0))
- return new
- end
- local vel
- local function DrawScreen()
- surface.SetDrawColor(0,0,0,120)
- surface.DrawRect(0,0,size,size)
- surface.SetDrawColor(200,230,255,255)
- surface.SetTextColor( 200, 230, 255, 255 )
- surface.SetFont("DefaultFixedOutline")
- local newvel = localtoworld(ENT:GetVelocity(), ENT:GetAngles()) * 0.5
- for i, part in pairs(sand) do
- vel = vel + newvel
- vel = vel + VectorRand() * 2
- sand[i].pos = sand[i].pos + (sand[i].vel * FrameTime())
- sand[i].vel = vel + (sand[i].vel * 0.99)
- if sand[i].pos.x < 0 then
- sand[i].pos.x = 1
- sand[i].vel.x = -sand[i].vel.x * math.random()
- end
- if sand[i].pos.x > size then
- sand[i].pos.x = size-1
- sand[i].vel.x = -sand[i].vel.x * math.random()
- end
- if sand[i].pos.y < 0 then
- sand[i].pos.y = 1
- sand[i].vel.y = -sand[i].vel.y * math.random()
- end
- if sand[i].pos.y > size then
- sand[i].pos.y = size-1
- sand[i].vel.y = -sand[i].vel.y * math.random()
- end
- drawpixel(i)
- end
- end
- local new = GetRenderTarget("test_rt", size, size, true)
- local function main()
- local old, w, h = render.GetRenderTarget(), ScrW(), ScrH()
- render.SetRenderTarget(new)
- -- render.Clear(68,112,146, 50, false)
- render.SetViewPort(0, 0, size, size)
- cam.Start2D()
- DrawScreen()
- cam.End2D()
- render.SetViewPort(0, 0, w, h)
- render.SetRenderTarget(old)
- end
- local mat = CreateMaterial("test_rt_mat", "VertexLitGeneric",
- {
- ["$basetexture"] = "test_rt",
- }
- )
- ENT:SetModelScale(Vector())
- function ENT:RenderOverride()
- main()
- SetMaterialOverride(mat)
- self:DrawModel()
- SetMaterialOverride()
- end
Advertisement
Add Comment
Please, Sign In to add comment