WIDTH = 60
HEIGHT = 10

pRed = GetFloatParam("Red", 255)
pGreen = GetFloatParam("Green", 255)
pBlue = GetFloatParam("Blue", 255)
pAlpha = GetFloatParam("Alpha", 1) 

function init()
	local locations = FindLocations("")
	locposes = {}
	locwidth = {}
	--for i=1, #locations do
		--locposes[i] = GetLocationTransform(locations[i])
	--	locposes[i].pos[2] = locposes[i].pos[2]+HEIGHT/2
	--end
	
	lws = GetLocationTransform(FindLocation("lws"))
	lwf = GetLocationTransform(FindLocation("lwf"))

	locposes[1] = lws
	locposes[1].pos[1] = lws.pos[1] 
	locposes[1].pos[2] = lws.pos[2] + HEIGHT/2
	locposes[1].pos[3] = lws.pos[3] + (lwf.pos[3]-lws.pos[3])/2
	locwidth[1] = (lwf.pos[3]-lws.pos[3])*2
	
	rws = GetLocationTransform(FindLocation("rws"))
	rwf = GetLocationTransform(FindLocation("rwf"))
	locposes[2] = rws
	locposes[2].pos[1] = rws.pos[1] 
	locposes[2].pos[2] = rws.pos[2] + HEIGHT/2
	locposes[2].pos[3] = rws.pos[3] + (rwf.pos[3]-rws.pos[3])/2
	locwidth[2] = (rwf.pos[3]-rws.pos[3])*2
	
	fws = GetLocationTransform(FindLocation("fws"))
	fwf = GetLocationTransform(FindLocation("fwf"))
	locposes[3] = fws
	locposes[3].pos[1] = fws.pos[1] + (fwf.pos[1]-fws.pos[1])/2
	locposes[3].pos[2] = fws.pos[2] + HEIGHT/2
	locposes[3].pos[3] = fws.pos[3] 
	locwidth[3] = math.abs(fwf.pos[1]-fws.pos[1])*2
	
	bws = GetLocationTransform(FindLocation("bws"))
	bwf = GetLocationTransform(FindLocation("bwf"))
	locposes[4] = bws
	locposes[4].pos[1] = bws.pos[1] + (bwf.pos[1]-bws.pos[1])/2
	locposes[4].pos[2] = bws.pos[2] + HEIGHT/2
	locposes[4].pos[3] = bws.pos[3] 
	locwidth[4] = math.abs(bwf.pos[1]-bws.pos[1])*2

	r,g,b = GetEnvironmentProperty("fogcolor")
	bordertexture = LoadSprite("images/border.png")
end

function tick()
	for i=1, #locposes do
		if not GetBool("level.sandbox") then
			DrawSprite(bordertexture, locposes[i], locwidth[i], HEIGHT, pRed/255, pGreen/255, pBlue/255, pAlpha, true, false)
		else
			DrawSprite(bordertexture, locposes[i], locwidth[i], HEIGHT, r, g, b, pAlpha, true, false)
		end
	end
end
