Hey,
i'm using Advanced Tiled Loader to load maps, and it's working great. However, i wanted the map to scroll when i moved and wrote this piece of code:
if love.keyboard.isDown("up", "w") then ty = ty + 250*dt
end
if love.keyboard.isDown("right", "d") then tx = tx - 250*dt
end
if love.keyboard.isDown("left", "a") then tx = tx + 250*dt
end
if love.keyboard.isDown("down", "s") then ty = ty - 250*dt
end
Unfortunately, that makes the player move one tile at a time How can i make it scroll "per pixel" instead? I looked up the "Fine Tile Scrolling" tutorial on the wiki but didn't really understand it.
My .love file is here: http://www.mediafire.com/?o92it7mpgp434ht
I use a camera and set the center into the player everytime it moves (the player can move one pixel at a time). Also, the camera has bounds on the map end so it doesn't show anything outside the map (the only way the player moves from the center of the screen). I use http://nova-fusion.com/2011/05/09/camer ... nt-bounds/
PS: Why the sound file? You don't play it and it's quite a big file.
Your movement actually is per-pixel. The blocky movement is a combination of love.graphics.scale() and flooring your love.graphics.translate() values. Since your pixels are 4x larger this will makes your screen move 4 pixels at a time. This is easier to see if you slow down your speed a lot. Instead of flooring your translation do this instead:
Kadoba wrote:Your movement actually is per-pixel. The blocky movement is a combination of love.graphics.scale() and flooring your love.graphics.translate() values. Since your pixels are 4x larger this will makes your screen move 4 pixels at a time. This is easier to see if you slow down your speed a lot. Instead of flooring your translation do this instead:
local ftx, fty = tx - tx % (1/scale), ty - ty %( 1/scale)
This is still flooring your values but in such a way that it will always move one pixel on your screen rather than the scaled up pixels.
I've reuploaded your game with the fix. You can change the scale with Q and E.
Thank you for your answer! Although, i have found that it was another problem that was causing this. I noticed the game was running at ~8 FPS, so i checked what was causing that and i found that i did not use Advanced Tiled Loader's