require 'grid' require 'point' require 'line' require 'mouse' require 'levelhandler' require 'button' require 'menu' Input = require 'input' function love.load() love.window.setMode( 800, 480 ) InMenu = true love.graphics.setLineStyle( Config.lineStyle ) end function love.update( dt ) InMenu = Menu.current_state ~= MenuStateIndex.hidden Mouse:update() Input:update() local exit = Input:actionReleased( 'exit' ) if InMenu then Menu:update( dt, Point:new( Mouse.x, Mouse.y ), Mouse.pressed ) else if Input:actionReleased( 'nextlevel' ) then if GameGrid:isCompleted() then GameGrid = LevelHandler:next() Menu.updateCellSize() end end end -- Switch menu state or exit if exit then if not InMenu then Menu.current_state = MenuStateIndex.pause elseif Menu.current_state == MenuStateIndex.start then love.event.quit() elseif Menu.current_state == MenuStateIndex.pause then Menu.current_state = MenuStateIndex.hidden elseif Menu.current_state == MenuStateIndex.levels then Menu.current_state = MenuStateIndex.start end end end function love.draw() if InMenu then love.graphics.setLineWidth( Config.menuLineWidth ) Menu:draw() else love.graphics.setLineWidth( Config.cellSize * Config.lineWidth ) 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 end