I've never made a game before and so I'm not sure how this is all supposed to work. I'm using Tiled with STI and am trying to get the Stalker-X camera to work with it. It seems to work just fine but it's quite apparent that both the world and the player are moving...ie doubling his movement speed. Despite looking fine I imagine this is not the way it should be working.
function love.update(dt)
world:update(dt)
map:update(dt)
camera:update(dt)
camera:follow(player.x, player.y)
-- Move map
local kd = love.keyboard.isDown
local l = kd("left") or kd("a")
local r = kd("right") or kd("d")
player.x = l and player.x - player.speed * dt or player.x
player.x = r and player.x + player.speed * dt or player.x
end
It calls love.graphics.origin before drawing anything meaning any effect applied beforehand (location, scale or rotation) is completely ignored.
While it does handle everything for you in regards to drawing, it's very limited in how it can draw the environment.
In other words. It can only work without rotation and you have to supply the appropriate translation yourself as parameters.
It is intended that you move both the player and the world. This should have no effect on the speed or visuals.
I'm guessing you've been scaling with your camera which would explain the speed differences.
Edit: So you can use a camera. But you are more limited and need to make sure to not use the player location but the camera location as parameter for STI maps. Since that's what you expect to draw.
Last edited by erasio on Mon Jan 22, 2018 8:20 am, edited 1 time in total.
erasio wrote: ↑Sun Jan 21, 2018 1:53 pm
STI doesn't work with other cameras.
It calls love.graphics.origin before drawing anything meaning any effect applied beforehand (location, scale or rotation) is completely ignored.
While it does handle everything for you in regards to drawing, it's very limited in how it can draw the environment.
In other words. It can only work without rotation or scaling and you have to supply the appropriate translation yourself.
It is intended that you move both the player and the world. This should have no effect on the speed or visuals.
I'm guessing you've been scaling with your camera which would explain the speed differences.
Edit: So you can use a camera. But you are more limited and need to make sure to not use the player location but the camera location as parameter for STI maps. Since that's what you expect to draw.
OK I see, that explains a lot then. I thought I was just doing it all wrong. But I thought normally people use STI with Tiled? At least I noticed Tiled is extremely popular. I want to use that camera so what should I use with Tiled? Thanks for your help.
hasen wrote: ↑Sun Jan 21, 2018 2:04 pm
OK I see, that explains a lot then. I thought I was just doing it all wrong. But I thought normally people use STI with Tiled? At least I noticed Tiled is extremely popular. I want to use that camera so what should I use with Tiled? Thanks for your help.
Truth be told. I have no idea.
Never looked closely enough at tiled. I tried removing graphics.origin() but it kinda broke for no reason I understood at that time and I just dealt with that limitation (and added scaling myself which was just extra parameters to love.draw and some extra code)
Last edited by erasio on Sun Jan 21, 2018 2:58 pm, edited 1 time in total.
hasen wrote: ↑Sun Jan 21, 2018 2:04 pm
OK I see, that explains a lot then. I thought I was just doing it all wrong. But I thought normally people use STI with Tiled? At least I noticed Tiled is extremely popular. I want to use that camera so what should I use with Tiled? Thanks for your help.
Trust be told. I have no idea.
Never looked closely enough at tiled. I tried removing graphics.origin() but it kinda broke for no reason I understood at that time and I just dealt with that limitation (and added scaling myself which was just extra parameters to love.draw and some extra code)
Hmm I see. So you do the levels in code? I wouldn't know how to do that. But it seems many people use Tiled with Love2d still though.