summaryrefslogtreecommitdiffstats
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua54
1 files changed, 46 insertions, 8 deletions
diff --git a/main.lua b/main.lua
index d2987ee..c9f63fb 100644
--- a/main.lua
+++ b/main.lua
@@ -1,9 +1,13 @@
-debugGraph = require 'vendor.debugGraph'
-inspect = require 'vendor.inspect'
+local debugGraph = require 'vendor.debugGraph'
+local inspect = require 'vendor.inspect'
+local push = require 'vendor.push'
+
+environment = os.getenv('ENV')
screens = {
+ require 'screens.weather',
+ require 'screens.time',
require 'screens.screen1',
- require 'screens.screen2',
}
state = {
@@ -15,18 +19,48 @@ state = {
stateCounter = 0,
}
+local gameWidth, gameHeight = 1280, 720
+local windowWidth, windowHeight = love.window.getDesktopDimensions()
+windowWidth, windowHeight = windowWidth*.5, windowHeight*.5 --make the window a bit smaller than the screen itself
+
+if environment == 'DEV' then
+ push:setupScreen(gameWidth, gameHeight, windowWidth, windowHeight, {fullscreen = false, resizable = true})
+else
+ push:setupScreen(gameWidth, gameHeight, gameWidth, gameHeight, {fullscreen = true})
+end
+
+function love.resize(w, h)
+ push:resize(w, h)
+ secondaryCanvas = love.graphics.newCanvas(push:getWidth(), push:getHeight())
+end
+
function love.load()
- love.window.setMode(1366, 768, {borderless=true})
+ love.mouse.setVisible( false )
+
+ secondaryCanvas = love.graphics.newCanvas(push:getWidth(), push:getHeight())
- secondaryCanvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight())
fpsGraph = debugGraph:new('fps', 0, 0)
memGraph = debugGraph:new('mem', 0, 30)
+
+ for key, node in ipairs(screens) do
+ node.load()
+ end
end
+function getw() return push:getWidth() end
+function geth() return push:getHeight() end
+
function love.draw()
- -- love.graphics.reset()
+ push:start()
+
+ -- Patch love.graphics.getWidth/Height to account for push
+ oldw, oldh = love.graphics.getWidth, love.graphics.getHeight
+ love.graphics.getWidth, love.graphics.getHeight = getw, geth
+
screens[state.currentScreen].render()
+
if state.transitioning then
+ -- Render next screen into canvas and fade accordingly
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)
@@ -34,11 +68,15 @@ function love.draw()
-- Draw graphs
love.graphics.setColor(255, 255, 255, 128)
- --love.graphics.setNewFont(10)
- --love.graphics.print(inspect(state), 0, 60, 0)
+
+ -- love.graphics.setNewFont(10)
+ -- love.graphics.print(inspect(state), 0, 60, 0)
fpsGraph:draw()
memGraph:draw()
+
+ love.graphics.getWidth, love.graphics.getHeight = oldw, oldh
+ push:finish()
end
function love.update(dt)