46 lines
1.1 KiB
Lua
46 lines
1.1 KiB
Lua
require 'grid'
|
|
require 'point'
|
|
require 'line'
|
|
require 'mouse'
|
|
require 'levelhandler'
|
|
Input = require 'input'
|
|
|
|
function love.load()
|
|
love.graphics.setLineStyle( Config.lineStyle )
|
|
love.graphics.setLineWidth( Config.lineWidth )
|
|
|
|
GameGrid = LevelHandler:first()
|
|
end
|
|
|
|
function love.update( dt )
|
|
Mouse:update()
|
|
Input:update()
|
|
|
|
if Input:actionReleased( 'exit' ) then
|
|
love.event.quit()
|
|
end
|
|
|
|
if Input:actionReleased( 'nextlevel' ) then
|
|
if GameGrid:isCompleted() then
|
|
GameGrid = LevelHandler:next()
|
|
end
|
|
end
|
|
end
|
|
|
|
function love.draw()
|
|
GameGrid:draw()
|
|
|
|
local text = string.format( "%d:%d global\n%d:%d local\n%d:%d from start", Mouse.x, Mouse.y, Mouse.point.x, Mouse.point.y, Mouse.startX - Mouse.x, Mouse.startY - Mouse.y )
|
|
love.graphics.print( text, 64, 256 )
|
|
|
|
if Mouse.dragged then
|
|
love.graphics.print( "drag", 64, 300 )
|
|
end
|
|
if Mouse.lastLine ~= nil then
|
|
love.graphics.print( tostring( Mouse.lastLine ), 128, 300 )
|
|
end
|
|
|
|
if GameGrid:isCompleted() then
|
|
love.graphics.print( "Grid completed. Press space to proceed to next", 64, 320 )
|
|
end
|
|
end
|