
---- Used for multi-frame "fire-and-forget" style effects ----
-------------------------------------------------------------------------------

Effects = {
	list = {}
}

function Effects:add(e)
	table.insert(self.list, e)
end

function Effects:draw()
	local i = 1 -- strange iteration method to allow self-removal ;)
	while self.list[i] do
		if self.list[i]:draw() then i = i+1 
		else table.remove(self.list, i) end
	end
end



NBomb = {
	x = 0, y = 0,
	frame = 0
}

function NBomb:new(x, y)
	nb = {}
	setmetatable(nb, self)
	self.__index = self
	self.x, self.y = x, y
	Effects:add(nb)
	Crysts:nuke()
	screen:flash(colors.nbflash)
	sfx.nbomb:playAt(x, y)
	return nb
end

function NBomb:draw()
	self.frame = self.frame + 1
	screen:setTint(colors.white50)
	screen.blitScaled(self.x-self.frame*8, self.y-self.frame*8, imgs.nbombnuke, self.frame/4, self.frame/4)
	screen:setTint()
	return (self.frame <= 30)
end
