56 lines
1.6 KiB
Lua
56 lines
1.6 KiB
Lua
|
|
local Time = require"time"
|
|
local Clock = require"clock"
|
|
|
|
function love.load()
|
|
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
|
|
|
local fontsize = love.graphics.getHeight() / 20
|
|
|
|
local margin = love.graphics.getHeight() / 20
|
|
|
|
local diameter = love.graphics.getHeight() - 2 * margin
|
|
local offset = diameter/2 + margin
|
|
local clockTransform = love.math.newTransform(offset, offset)
|
|
local clock = Clock:new(nil, diameter, clockTransform)
|
|
|
|
local column2X = diameter + 2*margin
|
|
|
|
clock.onSetHands = function(time)
|
|
local h, m = time:get()
|
|
end
|
|
|
|
local exitNote = "Press \"Esc\" to exit."
|
|
local exitNoteWidth = love.graphics.getWidth() - column2X - margin
|
|
local exitNoteFont = love.graphics.newFont(fontsize)
|
|
local _, wraps = exitNoteFont:getWrap(exitNote, exitNoteWidth)
|
|
local exitNoteY = love.graphics.getHeight() - table.maxn(wraps) * exitNoteFont:getHeight() - margin
|
|
|
|
love.graphics.setBackgroundColor(0.02,0.53,0.77)
|
|
|
|
|
|
function love.mousemoved(x, y, dx, dy, istouch)
|
|
clock:movemouse(x, y)
|
|
end
|
|
|
|
-- todo mousepressed & mousereleased
|
|
function love.mousepressed(x, y, button, istouch, presses)
|
|
clock:pressmouse(x, y, button)
|
|
end
|
|
|
|
function love.mousereleased(x, y, button, istouch, presses)
|
|
clock:releasemouse(button)
|
|
end
|
|
|
|
function love.draw()
|
|
clock:draw()
|
|
love.graphics.printf(exitNote, exitNoteFont, column2X, exitNoteY, exitNoteWidth)
|
|
end
|
|
end
|
|
|
|
function love.keypressed(key, scancode, isrepeat)
|
|
if scancode == "escape" then
|
|
love.event.quit()
|
|
end
|
|
end
|