
Explosion = Entity:createSubClass();
registerSpawn("Explosion");

function Explosion:init()

   self:setTexture("oldsprites.tga");

   self:setSpriteScale(2);

   setSpriteFromDef(self, 15, 1);

   self.animFrame = 0;
   self.myLight = Light_Basic:create();
   self.myLight:setSpriteScale(16);

   self:setLayer(3);

end

function Explosion:update()

   local animSpeed = 0.5;
   local animEnd = 3;

   self.animFrame = self.animFrame + animSpeed;

   if self.animFrame > animEnd + 0.99 then
      self:die();
   else
      setSpriteFromDef(self, 15, math.floor(self.animFrame) + 1, false);

      local lightAlpha = (animEnd - self.animFrame) / animEnd
      if lightAlpha >= 0 then
         self.myLight:setAlpha(lightAlpha);
      end

   end

end

function Explosion:setPos(x, y)

   self.myLight:setPos(x, y);
   
   Entity.setPos(self, x, y);

end

function Explosion:destruct()

   self.myLight:die();

end

