-- Load background drawing functions from bklist.txt
background = {}
local bkDraw = {}

local i = 0
local bklist = io.open("bklist.txt",IO.READ)
for line in bklist:lines()
	-- skip loading blank lines (empty slots)
	if #line > 0
		bkDraw[i] = include("Client/bk/"..line..".lua")
	end
	i = i+1 -- but incriment either way
end
bklist:close()
console.debug("Found "..#bkDraw.." background animation types.")

function background.think()
	if not bk return end
	bk.ticks = bk.ticks+1
end

-- Called to draw the background animations, or at least clear the screen.
-- This is the part you access from other files.
function background.draw(screen)
	if not bk return end
	if not bkDraw or not bkDraw[bk.move]
		screen.clear(bk.color or 0x000000) -- default to clearing the screen if bkMove not found.
	else
		bkDraw[bk.move](screen,bk.ticks,camera.x,camera.y) -- call the appropriate rendering function.
	end
end
