Candelabra = class(Decoration, { type = "Candelabra", display = Animation:new(animation.decoration.candelabra), }) function Candelabra:new(x,y) local light_data = {} light_data.radius = 100 light_data.color = hex2rgb("#fed100") local o = Decoration:new(x,y,animation.decoration.candelabra,light_data) o.particle_rate = 5 o.particle_count = 0 setmetatable(o, self) self.__index = self return o end function Candelabra:handleAnimation() if self.body.was_updated then self.particle_count = self.particle_count + 1 while self.particle_count >= self.particle_rate do local pos = math.floor(math.random(1,3))-2 local particle_data = {} particle_data.animation = animation.particle.simple particle_data.sprite_tint = hex2rgb("#ffffff") particle_data.sprite_alpha_fade = true particle_data.direction = -math.rad(90) particle_data.speed = 0.5 + math.random(2)*0.005 particle_data.time = 0.5+math.random(0.5) particle_data.animation_speed = 1/particle_data.time particle_data.func = function(self) --COSINE WAVE FUNCTION --init variables and constants self.t = self.t or 0 self.phase = self.phase or math.random(2*math.pi) local dt = 0.5 local amplitude = 0.5 local frequency = 0.5/game.framerate --calc self.t = self.t + dt self:moveX(amplitude*math.cos(2*math.pi*frequency*self.t+self.phase)) end Particle:new(self.pos.x+pos*5,self.pos.y-3,particle_data) self.particle_count = self.particle_count - self.particle_rate end end Decoration.handleAnimation(self) end