50 lines
1.2 KiB
Lua
50 lines
1.2 KiB
Lua
require 'grid'
|
|
require 'point'
|
|
require 'line'
|
|
require 'mouse'
|
|
|
|
function love.load()
|
|
love.graphics.setLineStyle( Config.lineStyle )
|
|
love.graphics.setLineWidth( Config.lineWidth )
|
|
|
|
GameGrid = Grid:new( Point:new( 5, 5 ) )
|
|
local line = Line:new(
|
|
GridPoint:new( 1, 1 ),
|
|
GridPoint:new( 3, 3 ),
|
|
Color.red
|
|
)
|
|
GameGrid:push( line )
|
|
local line1 = Line:new(
|
|
GridPoint:new( 1, 5 ),
|
|
GridPoint:new( 5, 2 ),
|
|
Color.green
|
|
)
|
|
GameGrid:push( line1 )
|
|
local line2 = Line:new(
|
|
GridPoint:new( 2, 5 ),
|
|
GridPoint:new( 5, 3 ),
|
|
Color.blue
|
|
)
|
|
GameGrid:push( line2 )
|
|
|
|
end
|
|
|
|
-- TODO: move input interactions into module
|
|
-- TODO: fix collision with other line's endpoint
|
|
function love.update( dt )
|
|
Mouse:update()
|
|
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
|
|
end
|