diff options
author | Piotr Dobrowolski <admin@tastycode.pl> | 2017-01-08 01:11:19 +0100 |
---|---|---|
committer | Piotr Dobrowolski <admin@tastycode.pl> | 2017-01-08 01:11:19 +0100 |
commit | ecb46842ae699f189580e2c12db548811549575f (patch) | |
tree | 634575b0a71e1f5eb70b47290cda894949805165 /screens/weather.lua | |
parent | 590af22cd8a4c696924cf33536ae0611be04728c (diff) | |
download | love2d-signage-ecb46842ae699f189580e2c12db548811549575f.tar.gz love2d-signage-ecb46842ae699f189580e2c12db548811549575f.tar.bz2 love2d-signage-ecb46842ae699f189580e2c12db548811549575f.tar.xz love2d-signage-ecb46842ae699f189580e2c12db548811549575f.zip |
Add weather and time screen
Diffstat (limited to 'screens/weather.lua')
-rw-r--r-- | screens/weather.lua | 55 |
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 |