The biggest issue the game still have has to do with scaling.
I managed to make the screen scale properly when you resize the game's windows, but the start size of backgrounds and objects are predefined on this file:
https://codeberg.org/glitchapp/fish-fil ... frgbck.lua at the function assignremakesize() which is simply a work around till I find the right formula to calculate it automatically.This basically a mathematical problem, any help to achieve this is welcome.
There are variables that store the windows width and height and the size of the maze in the game logic
--This code loads a game level in the push-blocks game. It sets the game map, grid size, block sizes and outlines, and areas. It also remaps the tiles, sets the block outline, and loads the agents for the level.
Code: Select all
function pb:load (level)
local width, height = love.graphics.getDimensions()
self.map = level.map
self.gridWidth = level.w
self.gridHeight = level.h
--self.gridSize = math.floor(math.min(width/(level.w), height/(level.h)))
self.gridSize = (math.min(width/(level.w), height/(level.h)))
tileSize = self.gridSize
gridSize=self.gridSize -- turns self.gridSize into a global variables needed to reset zoom values on game/mainfunctions/mouseinput.lua
self.blocks = level.blocks
self.areas = level.areas
for i, block in ipairs (self.blocks) do
remapTiles (block)
setBlockOutline (block)
end
pb:agentsload(level)
end
The variables that store the windows size are:
Code: Select all
local desktopWidth, desktopHeight = love.window.getDesktopDimensions()
The function assignremakesize() initializes the values expx, expy and dividx, dividy. Those values are factors used to resize the background of the levels and the objects / agents so that they align with the underliying grid. For now they are initialized manually but I'm looking for the formula that take all the variables share above and do that math.
Code: Select all
function assignremakesize()
if res=="720p" then expx=0.38 expy=0.38 dividx=0.75 dividy=0.75
elseif res=="1080p" then expx=0.52 expy=0.52 dividx=1.02 dividy=1.02
elseif res=="1440p" then expx=0.670 expy=0.670 dividx=1.33 dividy=1.33
elseif res=="4k" then expx=1.07 expy=1.07 dividx=2.1 dividy=2.1
end
I need to make a formula that take those values and initialize the level with proper scaling.