function debugUI()
	love.graphics.setScale()

	local mouse_x, mouse_y = love.mouse.getPosition()
	for _, light in pairs(LoadedObjects.Lights) do
		love.graphics.print(light.pos.x,light.pos.x,light.pos.y)
		love.graphics.print(light.pos.y,light.pos.x,light.pos.y+20)
		love.graphics.print(light.pos.x,light.pos.x,light.pos.y+40)
	end

	love.graphics.print("time: ".. tostring(math.floor(100*game.seconds_since_start)/100) .." fps: "..fps_current, 10*text_size, 0*text_size, 0, text_size)
	love.graphics.print(--[["CPUtime: "..checkCPUTime("total")..", CPU: "..(math.floor(checkCPUTime("get")*10000)/100).."%,]] "memory_usage: "..memory_usage.."kB", 10*text_size, 20*text_size, 0, text_size)

	love.graphics.setColor(1,1,1)
	-- lots of variables
	love.graphics.print("LoadedObjects",10*text_size,40*text_size, 0, text_size)
	local i = 1
	for k, v in pairs(LoadedObjects) do
		if type(v) == "table" then
			love.graphics.print("<"..k.."> ".. #v,10*text_size,(40+(10*i))*text_size, 0, text_size)
			i = i + 1
		end
	end
	love.graphics.setColor(1,0,0)
end

function debugColisions()
	love.graphics.setScale(game.scale)
	-- DrawColisionTable()
	LoadedObjects.drawCollisions()
end

function debugEntities()
	love.graphics.setScale(game.scale)
	for _, particle in pairs(LoadedObjects.Particles) do
		particle:debug()
	end
	for _, enty in pairs(LoadedObjects.Entities) do
		enty:debug()
	end
end

--[[CPUUsage = {}
function checkCPUTime(action, name)
	if name then
		if action == "start" then
			if CPUUsage.name == nil then CPUUsage.name = {} end
			CPUUsage.name.start = os.clock()
		elseif action == "fin" then
			CPUUsage.name.fin = os.clock()
			CPUUsage.name.use = CPUUsage.name.fin - CPUUsage.name.start
			if CPUUsage.name.total == nil then CPUUsage.name.total = 0 end
			CPUUsage.name.total = CPUUsage.name.total + CPUUsage.name.use
			print(CPUUsage.name.fin.." : "..CPUUsage.name.use.." : "..CPUUsage.name.total)
		elseif action == "get" then
			return CPUUsage.name.use
		elseif action == "total" then
			return CPUUsage.name.total
		else
			return CPUUsage.name.use
		end
	-- Totals
	else
		if action == "get" then
			local currentTotalCPU = 0
			for _, timings in ipairs(CPUUsage) do
				currentTotalCPU = currentTotalCPU + CPUUsage.timings.use
			end
			return currentTotalCPU
		elseif action == "total" then
			local currentTotalCPU = 0
			for _, timings in ipairs(CPUUsage) do
				currentTotalCPU = currentTotalCPU + CPUUsage.timings.total
			end
			return currentTotalCPU
		else
			local currentTotalCPU = 0
			for _, timings in ipairs(CPUUsage) do
				currentTotalCPU = currentTotalCPU + CPUUsage.timings.use
			end
			return currentTotalCPU
		end
	end
end]]

function logPrint(string)
	if logging then print(string) end
	logWrite(string)
end

function logWrite(string)
	if logging then logFile:write(string.."\n") end
end

local frameDebug_lines = {}

-- used for debug output that will be printed every frame
function frameDebug(str)
	table.insert(frameDebug_lines, str)
end

-- called at the end of each frame, draw everything passed to frameDebug this frame
function frameDebugFlush()
	local y = 0
	love.graphics.setColor(100, 100, 100, 0.8)
	for _, str in ipairs(frameDebug_lines) do
		love.graphics.print(str, 2, y)
		y = y + 10
	end
	frameDebug_lines = {}
end
