
-- ALLOC

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

-- INIT

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

SetTexture("dust")
SetBlendMode(kBlendNormal)
SetNumParticles(100)

pScale:Init(2.8)
--pScale:Init(0.1)
pColor:Init(Color(1, 1, 1, 0))

local px = 512
local py = 300
pPosition:Init(fRange(Vec2(-px, -py), Vec2(px, py)) + dLocus)

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

pSpin:Init(fRange(0, 2 * 3.1415927))
pSpinSpeed:Init(fRange(-1, 1))
pAge:Init(0)

-- ANIM

pScale:Anim(pScale + fTimeScale(1.0))

pColor:Anim(fFade(pAge, 
   Color(1, 1, 1, 0), 
   500, Color(0.5, 0.5, 0.5, 0.8), 
   1800, Color(1, 1, 1, 0)
))

pPosition:Anim(pPosition + fTimeScale(pVelocity))
--pVelocity:Anim(pVelocity + fTimeScale(Vec2(0, -100)))

pSpin:Anim(pSpin + fTimeScale(pSpinSpeed))
pUp:Anim(f2dRotation(pSpin))

pAge:Anim(pAge + fAge())

Anim(fExpire(fGreater(pAge, 4000)))

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