function spawner(depth)
	local data = {}
	
	for i,v in ipairs(spawnlist) do
		local s = v.dstart or 0
		local e = v.dend or 161
		
		if (depth >= s) and (depth <= e) then
			data = v
			break
		end
	end
	
	--MF_alert(tostring(data.spawns) .. ", " .. tostring(depth))
	local rnd = math.random(1, #data.spawns)
	local sdata = data.spawns[rnd]
	
	if (type(sdata) == "table") then
		for i,v in ipairs(sdata) do
			spawn(v)
		end
	else
		spawn(sdata)
	end
end

function spawn(name)
	if (string.len(name) > 0) then
		local side = math.random(1,3)
		local xpos = 0
		local ypos = math.random(96,screenh - 192)
		local xvel,yvel = 0,0
		
		local enemyid = 0
		local item = false
		if (string.sub(name, 1, 4) ~= "item") then
			enemyid = MF_create(name)
		else
			item = true
			enemyid = create_item(string.sub(name, 6),0,0)
		end
		
		if (side == 1) then
			xpos = -48
			xvel = math.random(100,500) * 0.01
			yvel = math.random(-200,200) * 0.01
		elseif (side == 2) then
			xpos = screenw + 48
			xvel = 0 - math.random(100,500) * 0.01
			yvel = math.random(-200,200) * 0.01
		elseif (side == 3) then
			ypos = screenh + 48
			xpos = math.random(96,screenw - 192)
			xvel = math.random(-200,200) * 0.01
			yvel = 0 - math.random(100,300) * 0.01
		end
		
		MF_setpos(enemyid,xpos,ypos)
		MF_setvalue(enemyid,XVEL,xvel)
		MF_setvalue(enemyid,YVEL,yvel)
		
		if item then
			MF_setgamepos(enemyid,xpos,ypos)
		else
			addfoe(enemyid)
		end
	end
end

spawnlist =
{
	{
		dend = 10,
		spawns = {"item_GEM","item_TRASH","item_TRASH","item_TRASH","item_POOP","item_POOP","item_POOP","item_POOP","","","","","",""},
	},
	{
		dstart = 11,
		dend = 30,
		spawns = {"item_GEM","item_TRASH","item_TRASH","item_TRASH","item_POOP","item_POOP","item_POOP","item_POOP","enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine","","","",""},
	},
	{
		dstart = 31,
		dend = 60,
		spawns = {"item_TRASH","item_POOP","item_POOP","enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine","","","",""},
	},
	{
		dstart = 61,
		dend = 100,
		spawns = {"enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine","enemy_seamine"},
	},
	{
		dstart = 101,
		spawns = {{"enemy_seamine","enemy_seamine"},{"enemy_seamine","enemy_seamine"},"enemy_seamine"},
	},
}