Mothback/code/debug.lua

99 lines
3.8 KiB
Lua
Raw Normal View History

2021-10-16 23:06:11 +00:00
function DebugUI()
local mouse_x, mouse_y = love.mouse.getPosition()
for _, light in pairs(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
2021-10-25 23:19:22 +00:00
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)
2021-10-16 23:06:11 +00:00
love.graphics.setColor(1,1,1)
-- lots of variables
love.graphics.print("[main_Player]",10*textScale,40*textScale, 0, textScale)
love.graphics.print("position: {"..main_Player.pos.x..", "..main_Player.pos.y.."}",10*textScale,60*textScale, 0, textScale)
love.graphics.print("velocity: {"..main_Player.vel.x..", "..main_Player.vel.y.."}",10*textScale,80*textScale, 0, textScale)
love.graphics.print("scale: {"..main_Player.sprite_scale.x..", "..main_Player.sprite_scale.y.."}",10*textScale,100*textScale, 0, textScale)
love.graphics.print("states: \"isOnGround\": "..tostring(main_Player.isOnGround),10*textScale,120*textScale, 0, textScale)
love.graphics.print("\"coyoteValue\": "..tostring(main_Player.coyoteValue),10*textScale,140*textScale, 0, textScale)
2021-10-16 23:06:11 +00:00
love.graphics.print("[Camera]",10*textScale,160*textScale, 0, textScale)
love.graphics.print("position: {"..Camera.pos.x..", "..Camera.pos.y.."}",10*textScale,180*textScale, 0, textScale)
love.graphics.print("size: {"..Camera.width..", "..Camera.height.."}",10*textScale,200*textScale, 0, textScale)
2021-10-16 23:06:11 +00:00
love.graphics.print("[Cursor]",10*textScale,220*textScale, 0, textScale)
love.graphics.print("position: {"..mouse_x+Camera.pos.x..", "..mouse_y+Camera.pos.y.."}",10*textScale,240*textScale, 0, textScale)
love.graphics.print(textScale,10*textScale,240*textScale, 0, textScale)
love.graphics.print("Level: "..levelNum.." / "..#levelList.." \""..currLevel.."\"",10*textScale,260*textScale, 0, textScale)
2021-10-16 23:06:11 +00:00
-- player isOnGroundCheck
love.graphics.setColor(1,0,0)
2021-10-16 23:06:11 +00:00
end
function DebugColisions()
LoadedObjects.DrawCollisions()
2021-10-16 23:06:11 +00:00
end
function DebugEntities()
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
2022-02-07 08:41:53 +00:00
function logWrite(string)
if logging then logFile:write(string.."\n") end
2022-02-07 08:41:53 +00:00
end