FPS issue with simple box2D game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Aaron51
Prole
Posts: 1
Joined: Wed Oct 19, 2016 3:39 am

FPS issue with simple box2D game

Post by Aaron51 »

Hey guys!

I just started working with love today but I have been struggling with this little FPS issue for a few hours. I know there are a lot of threads about FPS problems on this forum, but I couldn't find a solution after trying many of them. When I run the game, it is smooth as butter for about 10 seconds. After that, it will start to lag. It will not lag outrageously but it is definitely noticeable.

I draw the FPS on the screen of the game and it stays at 60 throughout since I limit it in love.update(). I also checked the cpu usage in Task Manager; it uses 2% of my cpu and about 34 MB of ram. I also checked garbage collection. I put the line collectgarbage("stop") in love.load() and it did not fix the issue.

I will attach my .love file to this post. It is not too complicated. If any of you have any guidance or ideas, please don't hesitate to let me know!
WormWhip.love
(2.34 KiB) Downloaded 143 times
controls
a -> counterclockwise rotation
d -> clockwise rotation

Thanks,
Aaron
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: FPS issue with simple box2D game

Post by ivan »

Good job on using a fixed time step.
First of all, getFPS is the number of frames that are drawn per second.
The hard-coded "physics interval" has nothing to do with drawing on the screen so your FPS will max out at 60 due to vsync.
To check your physics frame rate, you can use: physicsFrameRate = 1/(interval*steps)
I ran a profiler on your code and it didn't show any glaring bottlenecks.
The game runs fine so the lag may be caused by some other software on your machine.
collectgarbage("stop") in love.load() and it did not fix the issue.
Generally, I don't recommend turning off the GC in Lua.
It probably doesn't matter in this case, since love2d seems to control the garbage collection internally.

Good luck.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: FPS issue with simple box2D game

Post by raidho36 »

LÖVE does manual memory management internally, but once it's out in the Lua it's up to GC to handle it.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests