Page 1 of 3

Is there an effective way to cut down lag?

Posted: Sun Apr 08, 2018 8:24 pm
by icekiller8002
I have a game that I made with LÖVE2D. I want to update the game, but when I made the game compatible with löve 11.0, there's a ton of lag when I make the screen size bigger. I honestly don't know what's causing this, and I was wondering if there's an effective way to figure out the main problem for the lag, then remove it.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 3:56 am
by drunken_munki
If it is possible to attach the love file then do so, it would make it easier for people to help out. If not, then posting some of the code would help.

As it is now the problem might be too vague to solve.

On a random note I had a bunch of lag and stuttering on my older pc used for testing, for about two months or so. Turns out the g-card was dying and finally died last week. Anyway, does this happen on other games? Maybe check your drivers.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 5:05 am
by ivan
an effective way to figure out the main problem for the lag, then remove it.
Yes, there is a way to figure out which functions in your script take the longest time to execute, this is called profiling.
Personally, I use a small utility based on the debug.hook:
https://github.com/2dengine/profile.lua

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 8:34 pm
by icekiller8002
drunken_munki wrote: Mon Apr 09, 2018 3:56 am If it is possible to attach the love file then do so, it would make it easier for people to help out. If not, then posting some of the code would help.

As it is now the problem might be too vague to solve.

On a random note I had a bunch of lag and stuttering on my older pc used for testing, for about two months or so. Turns out the g-card was dying and finally died last week. Anyway, does this happen on other games? Maybe check your drivers.
This does not happen in other games. I would provide a .love file, but unless if you're willing to look through nearly 2000 lines of code, I don't wanna waste your time.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 8:40 pm
by Nixola
One doesn't necessarily need to read all of the code to figure out the issue; plus, two thousand lines of code may be a lot to one person but close to nothing for another one. I'd say you should upload the code (if you want to, of course) and let people decide whether they want to try, especially since it's the easiest way to figure out the issue.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 9:06 pm
by icekiller8002
Nixola wrote: Mon Apr 09, 2018 8:40 pm One doesn't necessarily need to read all of the code to figure out the issue; plus, two thousand lines of code may be a lot to one person but close to nothing for another one. I'd say you should upload the code (if you want to, of course) and let people decide whether they want to try, especially since it's the easiest way to figure out the issue.
Yeah, I agree with you. Well, if anyone wants to waste their time by looking through a script with 2K lines, be my guest.

Remember what I said: The lag issue only occurs when you have a big screen resolution.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 9:57 pm
by Nixola
I can't seem to notice any difference between 650x650 and 2560x1440 (which, as of now, is the highest I can go), so I'm afraid I'm unable to reproduce the issue and thus unable to test it.

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 9:58 pm
by yintercept
Does the lag issue happen when you changing window size/game resolution after start? Does it happen when going from windowed mode to full screen?

What are the specs of the machine you are running it on?

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 10:59 pm
by icekiller8002
I tried putting an FPS counter on the screen. When I get from 1000 x 700 to 1280 x 720, my framerate drops from 60 to 50. When I get from 1280 x 720 to 1366 x 768 (my computer monitor size), it drops from 50 to 30. Also, here's my specs:

Re: Is there an effective way to cut down lag?

Posted: Mon Apr 09, 2018 11:10 pm
by yintercept
Your .love file was taking ages for me to download, networks are fun like that.

Q - are you drawing all the images one at a time, or are you batching them and drawing from quads? If you're not drawing from quads try that--drawing individual images one after another is the first thing I would assume would cause problems especially if scaling up seems to impact fps.

If that fails, download and include the little profiler/utility library ivan suggested and tell us how it goes.