Mothback/code/debug.lua

96 lines
2.8 KiB
Lua

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: "..fps_total..", fps: "..fps_draw..", frametime: "..math.floor(current_dt* 1000).."ms", 10*textScale, 0*textScale, 0, textScale)
love.graphics.print(--[["CPUtime: "..checkCPUTime("total")..", CPU: "..(math.floor(checkCPUTime("get")*10000)/100).."%,]] "memoryUsage: "..memoryUsage.."kB", 10*textScale, 20*textScale, 0, textScale)
love.graphics.setColor(1,1,1)
-- lots of variables
love.graphics.print("LoadedObjects",10*textScale,40*textScale, 0, textScale)
local i = 1
for k, v in pairs(LoadedObjects) do
if type(v) == "table" then
love.graphics.print("<"..k.."> ".. #v,10*textScale,(40+(10*i))*textScale, 0, textScale)
i = i + 1
end
end
-- player isOnGroundCheck
--love.graphics.main_Player
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(LoadedParticles) 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