summaryrefslogtreecommitdiffstats
path: root/screens/weather.lua
diff options
context:
space:
mode:
Diffstat (limited to 'screens/weather.lua')
-rw-r--r--screens/weather.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/screens/weather.lua b/screens/weather.lua
new file mode 100644
index 0000000..df7a400
--- /dev/null
+++ b/screens/weather.lua
@@ -0,0 +1,55 @@
+local node = {}
+
+local inspect = require('vendor.inspect')
+
+local weatherFont = love.graphics.newFont('fonts/weathericons-regular-webfont.ttf', 400)
+local textFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 300)
+local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 20)
+
+local weatherGlyphs = {
+ snow = "",
+ mist = "",
+}
+
+local updateInterval = 60
+local lastUpdate = 0
+local state = {
+ weather = "snow",
+ temperature = 0,
+}
+
+function node.load()
+end
+
+function node.unload()
+end
+
+function node.render()
+ love.graphics.setColor( 0, 0, 0 )
+ love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
+
+ love.graphics.setColor( 255, 255, 255 )
+
+ love.graphics.setFont(textFont);
+ love.graphics.printf(tostring(state.temperature) .. "°", 600, 180, 650, 'center');
+
+ love.graphics.setFont(weatherFont);
+ love.graphics.print(tostring(weatherGlyphs[state.weather]), 150, 0);
+
+ love.graphics.setFont(smallFont)
+ love.graphics.printf("piździ x---DD", 0, love.graphics.getHeight() - 40, love.graphics.getWidth(), 'center')
+end
+
+function node.update(dt)
+ if lastUpdate < love.timer.getTime() - updateInterval then
+ lastUpdate = love.timer.getTime()
+ print("update")
+ print(inspect(state))
+ local updateThread = love.thread.newThread('screens/weather_thread.lua')
+ updateThread:start()
+ end
+
+ state = love.thread.getChannel('weather'):pop() or state
+end
+
+return node