Scaling drawing

This commit is contained in:
Alexey 2025-07-03 15:11:46 +03:00
commit 293f529613
6 changed files with 30 additions and 12 deletions

View file

@ -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