Page 1 of 1

Tilemap scroll laggy (but not always)

Posted: Tue Mar 24, 2020 2:59 pm
by Tabaqui
Hi all! In the last week i've been trying to develop a 2d jrpg with love.
After completing the tilemap scrolling system, i've noticed that sometimes it is laggy (without framerate drop) and i can't understand why. I've tried "flooring" tile and characters coordinates without results, so i've decided to post here my project to see if it's just an impression or if it's a real problem.

The first tilemap is as big as the screen, so you won't see problems there, but if you speak with the female npc with brown hair (with z, enter or spacebar) you will be teleported, after a couple of italian dialogues, to a bigger area where the scrolling problems occurs.

If you want to take a look at the code (quite a lot of files) i think you should look "game/Area.lua", "game/Player.lua", "game/Character.lua" and "game/Tilemap.lua" first and then main.lua.

Thank you in advance

PS.
i don't own the graphics used in this game

Re: Tilemap scroll laggy (but not always)

Posted: Wed Mar 25, 2020 2:29 am
by pgimeno
Hi Tabaqui, welcome to the forums!

I don't see lag, I see tearing problems inherent to having vsync off. Enabling vsync solved them for me. Have you tried that already?

Re: Tilemap scroll laggy (but not always)

Posted: Wed Mar 25, 2020 3:16 pm
by Tabaqui
Thank you, vsync seems to do the trick. Is vsync always capping fps at 60 on every system or should i start using dt to have the game running at constant speed everywhere? Thanks in advance

Re: Tilemap scroll laggy (but not always)

Posted: Wed Mar 25, 2020 3:21 pm
by Varkas
VSync depends on the refresh rate of the screen. 60Hz is a frequent number, but 50 and 70 are too, and I think modern screens offer up 200. So, no, vsync doesn't cap at 60 FPS, it depends on the screen and the screen settings.

Re: Tilemap scroll laggy (but not always)

Posted: Wed Mar 25, 2020 5:38 pm
by pgimeno
See e.g. https://www.maketecheasier.com/what-is-vsync/

Vsync or not vsync? Well, with vsync, you can't quantify how well is your program able to keep up with a normal monitor's refresh rate. Without vsync, you don't see the game as it is designed to work, and the tearing appears.

So, you probably want to use a key to toggle it, to let you monitor your FPS.