Fairy lights

This commit is contained in:
lustlion
2022-01-20 14:06:40 +01:00
parent 2d8b8a23db
commit ed9873d633
4 changed files with 30 additions and 3 deletions

View File

@@ -25,6 +25,11 @@ Particle = Entity:New(x,y)
y = o.speed * math.sin(o.direction)
}
if particle_data.light ~= nil then
o.lightRange = particle_data.light
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
end
-- animations
o.body = Animation:New(particle_data.animation)
o:centerOffset(o.body)
@@ -41,6 +46,9 @@ Particle = Entity:New(x,y)
end
function Particle:Kill()
if self.light ~= nil then
KillLight(self.light)
end
if self.id ~= nil then
for _, e in pairs(LoadedParticles) do
if e.id > self.id then
@@ -56,6 +64,9 @@ function Particle:HandleAnimation()
self.body:Animate()
self.timer = self.timer + current_dt
self.sprite_alpha = (self.time-self.timer)/self.time
if self.light ~= nil then
self.light.range = self.lightRange * self.sprite_alpha/2
end
if self.sprite_alpha < 0 then self:Kill() end
self:Draw(self.body)
end