Scaling drawing
This commit is contained in:
parent
d4c4c7bfd0
commit
293f529613
6 changed files with 30 additions and 12 deletions
15
main.lua
15
main.lua
|
|
@ -5,11 +5,19 @@ require 'mouse'
|
|||
require 'levelhandler'
|
||||
Input = require 'input'
|
||||
|
||||
function love.load()
|
||||
love.graphics.setLineStyle( Config.lineStyle )
|
||||
love.graphics.setLineWidth( Config.lineWidth )
|
||||
local function updateCellSize()
|
||||
local width, height = love.graphics.getDimensions()
|
||||
local gridX, gridY = GameGrid.size:coords();
|
||||
local isWidthBased = (width / height) / (gridX / gridY)
|
||||
Config.cellSize = math.floor(isWidthBased and height / gridY or width / gridX)
|
||||
love.graphics.setLineWidth( Config.cellSize * Config.lineWidth )
|
||||
end
|
||||
|
||||
function love.load()
|
||||
GameGrid = LevelHandler:first()
|
||||
updateCellSize()
|
||||
|
||||
love.graphics.setLineStyle( Config.lineStyle )
|
||||
end
|
||||
|
||||
function love.update( dt )
|
||||
|
|
@ -23,6 +31,7 @@ function love.update( dt )
|
|||
if Input:actionReleased( 'nextlevel' ) then
|
||||
if GameGrid:isCompleted() then
|
||||
GameGrid = LevelHandler:next()
|
||||
updateCellSize()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue