-- Rasterizer (folder->StarterPlayerScripts)
-- Thread (actor->Rasterizer_folder)
-- Scale = 1
-- Rasterizer (LocalScript->Rasterizer_folder) code:
local plr = game:GetService("Players").LocalPlayer
local thread = script.Parent.Thread
local p, q = 4,4 --divides the screen into threadX * threadY pieces to be updated independently using actors.
function Rasterize()
for i = 1, p do
for j = 1, q do
local newThread = thread:Clone()
newThread.Main:SetAttribute("Position", Vector2.new(i,j))
newThread.Parent = plr.PlayerGui
newThread.Main.Enabled = true
end
end
end
plr.CharacterAdded:Connect(Rasterize)
-- DebrisCollector (ModuleScript->Thread_actor)
local DebrisCollector = {}
DebrisCollector.WaitingQueue = {}
function removeElementFromTable(list : {}, element : any)
assert(typeof(list) == 'table', 'Expected type table, got type '..typeof(list)..'.')
local ele = table.find(list, element)
if not ele then
return
else
table.remove(list, ele)
end
end
function DebrisCollector.AddItem(instance : Instance, lifetime : number)
if not instance then return end
lifetime = lifetime or 0
assert(typeof(instance) == 'Instance', '[[Debris Collector]][.AddItem] Argument #1 must be of type Instance.')
assert(typeof(lifetime) == 'number', '[[Debris Collector]][.AddItem] Argument #2 must be of type number.')
table.insert(DebrisCollector.WaitingQueue, instance)
task.delay(lifetime, function()
if table.find(DebrisCollector.WaitingQueue, instance) then
instance:Destroy()
end
end)
end
function DebrisCollector.RemoveItem(instance : Instance)
if not instance then return end
removeElementFromTable(DebrisCollector.WaitingQueue, instance)
end
function DebrisCollector.GetWaitingQueueSize()
return #DebrisCollector.WaitingQueue
end
return DebrisCollector
-- PoolService (ModuleScript->Thread_actor)
local FramePool = script:WaitForChild('FramePool')
local debrisCollector = require(script.Parent.DebrisCollector)
local POOL_CAP : number = 200
local tempLifetime : number = 30 --in seconds
local poolService = {}
function poolService.AddFrame(frame : Frame)
frame.Parent = FramePool
if poolService.GetPoolQuantity() > POOL_CAP then
debrisCollector.AddItem(frame, tempLifetime)
end
end
function poolService.GetFrame() : Frame
if #FramePool:GetChildren() > 0 then
local f = FramePool.Frame
debrisCollector.RemoveItem(f)
return FramePool.Frame
else
local frame = Instance.new("Frame")
frame.AnchorPoint = Vector2.new(0.5, 0.5)
frame.BorderSizePixel = 0
frame.Parent = FramePool
return frame
end
end
function poolService.GetPoolQuantity() : number
return #FramePool:GetChildren()
end
return poolService
-- FramePool (folder->PoolService_ModuleScript)
-- Pixels (ScreenGUI->Thread_actor)
-- ZIndexBehavior = Sibling
To embed this project on your website, copy the following code and paste it into your website's HTML: