Added memmory usage to debug menu and logging
This commit is contained in:
parent
ed3d8a90ec
commit
b4311064f6
|
@ -1,36 +1,35 @@
|
||||||
function DebugUI()
|
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
|
||||||
|
|
||||||
local mouse_x, mouse_y = love.mouse.getPosition()
|
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)
|
||||||
|
|
||||||
for _, light in pairs(Lights) do
|
love.graphics.setColor(1,1,1)
|
||||||
love.graphics.print(light.pos.x,light.pos.x,light.pos.y)
|
-- lots of variables
|
||||||
love.graphics.print(light.pos.y,light.pos.x,light.pos.y+20)
|
love.graphics.print("[main_Player]",10*textScale,40*textScale, 0, textScale)
|
||||||
love.graphics.print(light.pos.x,light.pos.x,light.pos.y+40)
|
love.graphics.print("position: {"..main_Player.pos.x..", "..main_Player.pos.y.."}",10*textScale,60*textScale, 0, textScale)
|
||||||
end
|
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)
|
||||||
|
|
||||||
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("[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)
|
||||||
|
|
||||||
love.graphics.setColor(1,1,1)
|
love.graphics.print("[Cursor]",10*textScale,220*textScale, 0, textScale)
|
||||||
-- lots of variables
|
love.graphics.print("position: {"..mouse_x+Camera.pos.x..", "..mouse_y+Camera.pos.y.."}",10*textScale,240*textScale, 0, textScale)
|
||||||
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)
|
|
||||||
|
|
||||||
love.graphics.print("[Camera]",10*textScale,160*textScale, 0, textScale)
|
love.graphics.print(textScale,10*textScale,240*textScale, 0, textScale)
|
||||||
love.graphics.print("position: {"..Camera.pos.x..", "..Camera.pos.y.."}",10*textScale,180*textScale, 0, textScale)
|
love.graphics.print("Level: "..levelNum.." / "..#levelList.." \""..currLevel.."\"",10*textScale,260*textScale, 0, textScale)
|
||||||
love.graphics.print("size: {"..Camera.width..", "..Camera.height.."}",10*textScale,200*textScale, 0, textScale)
|
|
||||||
|
|
||||||
love.graphics.print("[Cursor]",10*textScale,220*textScale, 0, textScale)
|
-- player isOnGroundCheck
|
||||||
love.graphics.print("position: {"..mouse_x+Camera.pos.x..", "..mouse_y+Camera.pos.y.."}",10*textScale,240*textScale, 0, textScale)
|
love.graphics.setColor(1,0,0)
|
||||||
|
|
||||||
love.graphics.print(textScale,10*textScale,240*textScale, 0, textScale)
|
|
||||||
love.graphics.print("Level: "..levelNum.." / "..#levelList.." \""..currLevel.."\"",10*textScale,260*textScale, 0, textScale)
|
|
||||||
|
|
||||||
-- player isOnGroundCheck
|
|
||||||
love.graphics.setColor(1,0,0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function DebugColisions()
|
function DebugColisions()
|
||||||
|
@ -45,3 +44,46 @@ function DebugEntities()
|
||||||
enty:Debug()
|
enty:Debug()
|
||||||
end
|
end
|
||||||
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]]
|
||||||
|
|
17
main.lua
17
main.lua
|
@ -1,4 +1,6 @@
|
||||||
function love.load()
|
function love.load()
|
||||||
|
--logging = true
|
||||||
|
if logging then print("love: "..collectgarbage("count").." kB") end
|
||||||
arrow = 0
|
arrow = 0
|
||||||
|
|
||||||
do_pause = false
|
do_pause = false
|
||||||
|
@ -54,6 +56,9 @@ function love.load()
|
||||||
--CursedBook:New(180,68)
|
--CursedBook:New(180,68)
|
||||||
|
|
||||||
gravity = 0.2
|
gravity = 0.2
|
||||||
|
-- Debug and log stuff
|
||||||
|
memoryUsage, dtcount = 0, 0
|
||||||
|
if logging then print("mothback: "..collectgarbage("count").." kB, Loading time: "..os.clock().." seconds") end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
@ -68,6 +73,18 @@ function love.update(dt)
|
||||||
fps_count = fps_count + 1
|
fps_count = fps_count + 1
|
||||||
current_dt = dt
|
current_dt = dt
|
||||||
|
|
||||||
|
-- things per second
|
||||||
|
dtcount = dtcount + dt
|
||||||
|
if dtcount >= 1 then
|
||||||
|
if secs == nil then secs = 0 end
|
||||||
|
secs = secs + 1
|
||||||
|
dtcount = dtcount - 1
|
||||||
|
if debug or logging then
|
||||||
|
memoryUsage = math.floor(collectgarbage("count"))
|
||||||
|
end
|
||||||
|
if logging then print("Second "..secs..": "..memoryUsage.." kB") end
|
||||||
|
end
|
||||||
|
|
||||||
--keypressed
|
--keypressed
|
||||||
if Keybind:HasPressed(Keybind.menu.pause) then
|
if Keybind:HasPressed(Keybind.menu.pause) then
|
||||||
if do_pause then
|
if do_pause then
|
||||||
|
|
Loading…
Reference in New Issue