I want the below code to work every frame except "local particles = ..."
Code: Select all
local ParticleManager = [[
local Particles = ...
local dt = love.timer.getDelta()
for pIndex, Particle in pairs(Particles)
do
if Particle.timer > Particle.dissappearTime then
table.remove(Particles, pIndex)
Particle = nil
else
Particle.PosX = Particle.PosX + (Particle.directionX * Particle.speed * (1 - (Particle.timer / Particle.dissappearTime))) * dt
Particle.PosY = Particle.PosY + (Particle.directionY * Particle.speed * (1 - (Particle.timer / Particle.dissappearTime))) * dt
Particle.timer = Particle.timer + dt
end
end
]]
Code: Select all
function CreateThread(Particles)
-- Creates a new thread and start it
local Manager = love.thread.newThread(ParticleManager)
Manager:start(Particles)--gotta run this every frame and pass the table of particles
--And this needs dt
end