
-- ALLOC

pVelocity = Allocate(2)
pAge = Allocate(1)

-- INIT

if not dLocus then
   dLocus = Vec2(0, 0)
end

if not dRect then
   dRect = Allocate(4)
end

SetTexture("fire1")
SetBlendMode(kBlendNormal)
SetNumParticles(5)

pScale:Init(0.2)
pColor:Init(Color(0, 0, 0, 0))

local px = 20
local py = 10
pPosition:Init(fRange(Vec2(-px, -py), Vec2(px, py)) + dLocus)
--pPosition:Init(fRange(Vec2(dRect[1], dRect[2]), Vec2(dRect[3], dRect[4])) + dLocus)

local vx = 15
local vy = 100
pVelocity:Init(fRange(Vec2(-vx, -vy), Vec2(vx, -vy)))

pAge:Init(0)

-- ANIM

--pScale:Anim(pScale + fTimeScale(0.3))
pColor:Anim(fFade(pAge, 
   Color(1, 1, 1, 0), 
   200, Color(1, 1, 1, 0),
   400, Color(1, 1, 1, 0), 
   400, Color(0.8, 0.8, 0.8, 0.05), 
   400, Color(0.8, 0.8, 0.8, 0)
))

pPosition:Anim(pPosition + fTimeScale(pVelocity))
pVelocity:Anim(pVelocity + fTimeScale(Vec2(0, 0)))
pAge:Anim(pAge + fAge())

Anim(fExpire(fGreater(pAge, 2000)))

gActive = true
function Update(seconds)
   if gActive then
      CreateParticles(seconds * 2)
   end
end
