io.write("Acid-Maker included!\n")

--
-- required files:
--  * acid1.bmp - acid6.bmp
--  * acid_deep.bmp
--
-- use with:
--  Acid:new(x, y);
--

Acid = {
	gfx_surface = {
			[1] = bs.gfx.load("acid1.bmp"),
			[2] = bs.gfx.load("acid2.bmp"),
			[3] = bs.gfx.load("acid3.bmp"),
			[4] = bs.gfx.load("acid4.bmp"),
			[5] = bs.gfx.load("acid5.bmp"),
			[6] = bs.gfx.load("acid6.bmp")
	},
	gfx_deep=bs.gfx.load("acid_deep.bmp"),
	obj_cnt = 0
};
function Acid:new(x,y,is_surface)
    local obj = {};
    setmetatable(obj, self);
    self.__index = self;
    obj.is_surface=is_surface;
    if is_surface==1 then
        obj.animationFrame = math.random(6);
        obj.fgobject = bs.obj.new((x-1)*32, (y-1)*32, obj.gfx_surface[obj.animationFrame], "visible,ontop,killing");
    else
        obj.fgobject=bs.obj.new((x-1)*32, (y-1)*32, obj.gfx_deep, "visible,ontop,killing");
    end
    self.obj_cnt = self.obj_cnt + 1;
    self[self.obj_cnt] = obj;
end

bs.timer.new("AcidTimer", 0.1);

function AcidTimer ()
	for i = 1, Acid.obj_cnt do
	        if Acid[i].is_surface==1 then
		    Acid[i].animationFrame = math.mod(Acid[i].animationFrame, 6) + 1;
		    Acid[i].fgobject.gfx(Acid.gfx_surface[Acid[i].animationFrame]);
		end
	end
end
