72 lines
1.8 KiB
Lua
72 lines
1.8 KiB
Lua
debugGraph = require 'vendor.debugGraph'
|
|
inspect = require 'vendor.inspect'
|
|
|
|
screens = {
|
|
require 'screens.screen1',
|
|
require 'screens.screen2',
|
|
}
|
|
|
|
state = {
|
|
currentScreen = 1,
|
|
state = 'running',
|
|
cycleTime = 3,
|
|
transitionTime = 1,
|
|
transitioning = false,
|
|
stateCounter = 0,
|
|
}
|
|
|
|
function love.load()
|
|
love.window.setMode(1366, 768, {borderless=true})
|
|
|
|
secondaryCanvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight())
|
|
fpsGraph = debugGraph:new('fps', 0, 0)
|
|
memGraph = debugGraph:new('mem', 0, 30)
|
|
end
|
|
|
|
function love.draw()
|
|
-- love.graphics.reset()
|
|
screens[state.currentScreen].render()
|
|
if state.transitioning then
|
|
secondaryCanvas:renderTo(screens[state.currentScreen % #screens + 1].render)
|
|
love.graphics.setColor(255, 255, 255, 255 * (state.stateCounter / state.transitionTime)) -- red, green, blue, opacity (this would be white with 20% opacity)
|
|
love.graphics.draw(secondaryCanvas, 0, 0)
|
|
end
|
|
|
|
-- Draw graphs
|
|
love.graphics.setColor(255, 255, 255, 128)
|
|
--love.graphics.setNewFont(10)
|
|
--love.graphics.print(inspect(state), 0, 60, 0)
|
|
|
|
fpsGraph:draw()
|
|
memGraph:draw()
|
|
end
|
|
|
|
function love.update(dt)
|
|
screens[state.currentScreen].update(dt)
|
|
|
|
if state.transitioning then
|
|
screens[state.currentScreen % #screens + 1].update(dt)
|
|
end
|
|
|
|
state.stateCounter = state.stateCounter + dt
|
|
|
|
if state.transitioning then
|
|
if state.stateCounter >= state.transitionTime then
|
|
state.stateCounter = 0
|
|
state.transitioning = false
|
|
state.currentScreen = (state.currentScreen % #screens) + 1
|
|
end
|
|
else
|
|
if state.stateCounter >= state.cycleTime then
|
|
state.stateCounter = 0
|
|
state.transitioning = true
|
|
end
|
|
end
|
|
|
|
-- Update the graphs
|
|
fpsGraph:update(dt)
|
|
memGraph:update(dt)
|
|
|
|
require("vendor.lurker").update()
|
|
end
|