So the camera panning in my tile map level leaves a lot to be desired...not smooth. Can't figure out why, because fps is fine and I render less tiles on average than whats on the screen. Here's the class that most likely has the problem: https://pastebin.com/TtrWcwc8
one of the past versions of this class had much smoother panning, but other problems: https://pastebin.com/TtrWcwc8
to visit my repo on github so you can recreate it please visit: https://github.com/GCGsauce/RPG-Game-LUA
one can go to the second commit and run that to see the smooth panning, just make sure to copy the libraries folder to that project directory. thanks!
Camera panning not so smooth in map object
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Camera panning not so smooth in map object
Looks like you're missing deltatime when the camera position changes;
Something like this:
Map:update(dt)
You'll probably want to increase "2" to a higher value also. The problem would be, that as it's not sync'd with delta time, every time the fps drops/increase the camera will end up moving variable to the actual framerate. So make sure you multiply by dt to factor that in.
Something like this:
Map:update(dt)
Code: Select all
function Map:update(dt) --moves the map 1 pixel in any direction
if input:down('PAN_RIGHT') then
self.camX = self.camX + 2 *dt
print(self.camX)
elseif input:down('PAN_LEFT') then
self.camX = self.camX - 2 *dt
end
if input:down('PAN_UP') then
self.camY = self.camY - 2 *dt
elseif input:down('PAN_DOWN') then
self.camY = self.camY + 2 *dt
end
end
Who is online
Users browsing this forum: Google [Bot] and 4 guests