local module = createModule()

module.params.sprite = 14
module.params.lifeTime = 45
module.params.size = 30
module.params.redMin = 255
module.params.redMax = 255
module.params.greenMin = 128
module.params.greenMax = 192
module.params.blueMin = 128
module.params.blueMax = 192

local trails

local function trailParts(mesh)
	local part = createSpritePart(trails) -- create a particle of the "trails" group

	part.emitterIndex = getLaraIndex()
	part.emitterNode = mesh
	
	part.lifeSpan = module.params.life
	part.sizeStart = randomInt(module.params.size, module.params.size * 2)
	part.sizeEnd = part.sizeStart * 2

	part.colStart.r = randomInt(module.params.redMin, module.params.redMax)
	part.colStart.g = randomInt(module.params.greenMin, module.params.greenMax)
	part.colStart.b = randomInt(module.params.blueMin, module.params.blueMax)
	part.colEnd = part.colStart

	local d = 32
	part.pos = createVector(randomFloat(-d, d), randomFloat(-d, d), randomFloat(-d, d))

	part.spriteIndex = module.params.sprite
	part.fadeIn = 15
	part.fadeOut = 30
end 

local function trailInit()
	-- check if Lara is airborne
	if (Lara.fallSpeed ~= 0) then
		trailParts(3)  -- spawn on mesh 3
		trailParts(6)  -- spawn on mesh 6
		trailParts(10) -- spawn on mesh 10
		trailParts(13) -- spawn on mesh 13
	end
end

trails = createGroup(trailInit, nil)