I'm trying to implement STI (Simple Tiled Implementation) in my code.. but I have a problem with the tutorial code
when it comes to the "love.graphics.scaling" and "love.graphics.translate" parts at the end of the tutorial (to keep the player centered to screen while
scrolling the level around).
https://github.com/karai17/Simple-Tiled ... -to-sti.md
Everything works.. except the "scaling und translating" parts.
In other words: My program just seems to ignore the lines with "scale" and "translate" ..
Code: Select all
function love.draw()
-- Scale world
local scale = 2
local screen_width = love.graphics.getWidth() / scale
local screen_height = love.graphics.getHeight() / scale
-- Translate world so that player is always centred
local player = map.layers["Sprites"].player
local tx = math.floor(player.x - screen_width / 2)
local ty = math.floor(player.y - screen_height / 2)
-- Transform world
love.graphics.scale(scale)
love.graphics.translate(-tx, -ty)
-- Draw world
map:draw()
end
like there is no translate active (and is leaving the window of course if it gets outside the boundaries)
The code is pretty much "copy & paste" from the tutorial, some lines adapted to different asset names, but that's it..
Any ideas where I might search for the problem?