Noob Question: my game feels laggy?

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
User avatar
Marcus Aseth
Prole
Posts: 14
Joined: Wed Apr 05, 2017 11:56 am

Noob Question: my game feels laggy?

Post by Marcus Aseth »

Hi everyone, I'm new here and I was trying to do my first breaker game, problem is...it kind of feels laggy?!
Can you take a look at it to see what I am doing wrong and suggest me what to do to have it running as smooth as silk? :awesome:

Here's the game (170 lines or something) ->
Breaker.rar
(7.23 KiB) Downloaded 245 times
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Noob Question: my game feels laggy?

Post by Tanner »

On my machine, your game runs at 60 FPS. In fact, it runs so well that, according to the LuaJIT profiler, most of the CPU time is spent in the engine and your draw function only accounts for a measly 3%. If you're seeing bad performance, it's possible that you need to update your graphics drivers. Maybe check if other Love games run poorly as well.
User avatar
Marcus Aseth
Prole
Posts: 14
Joined: Wed Apr 05, 2017 11:56 am

Re: Noob Question: my game feels laggy?

Post by Marcus Aseth »

Thanks for checcking Tanner, though actually I coul have explained my problem a little better, is not like constant lag, is like a frame drop but very subtle, maybe I run it once and it seems to be ok, then I run it again and watching carefuly, I notice a subtle drop in the frame-rate for an instant. I printed the fps to console and is constant to 60...is it my immagination? x_x
I don't know... :\

Edit : it actually become more noticeable if you slow the ball speed and stare one of them, you'll see it's movement is not smooth at all :\ (that, or optical illusion.. x_x)

Edit2: I've added this code to the love.draw function:

Code: Select all

  
  local delta = love.timer.getDelta()
  love.graphics.print(string.format("%.3f", delta), 10, 10)
And it prints a number that constantly oscillate between 0.016 and 0.017, and I think it's the reason for the image not looking smooth. There is a way for me to stabilize that?
Image
User avatar
Marcus Aseth
Prole
Posts: 14
Joined: Wed Apr 05, 2017 11:56 am

Re: Noob Question: my game feels laggy?

Post by Marcus Aseth »

Setting that problem aside, now I've added simple rectangular collisions but the balls often tend to get stuck to the pad or to themselves, especially if you "ram" them with the side of the pad. Any idea why that happens? :crazy:

version with collisions -->
Breaker1.1.rar
(7.97 KiB) Downloaded 226 times
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Noob Question: my game feels laggy?

Post by zorg »

Delta time fluctuating should not be an issue, dare i say it's normal. You multiply speeds with it so that the game plays with the same speed on every device, for every user.

Also, do yourself a favour, and:
- Compress the contents of your project's directory, not the directory itself
- Use zip (not 7zip) instead of rar
- Finally, edit the extension to .love
Reason being people tend to be more helpful if they don't need to jump through unnecessary extra hoops to get your game running. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Noob Question: my game feels laggy?

Post by bartbes »

Marcus Aseth wrote: Sat Apr 08, 2017 4:31 pm the balls often tend to get stuck to the pad or to themselves
This is usually caused by collision code "flipping" the direction, but not ensuring the collision ends (or is ignored). That way, if the next update the ball hasn't left the object it collides with, its direction gets flipped again, back into the object. Two possible solutions might be to "eject" the ball from the object when you detect collision, or to always make sure the ball's direction is away from the object, rather than just flipped.
User avatar
Marcus Aseth
Prole
Posts: 14
Joined: Wed Apr 05, 2017 11:56 am

Re: Noob Question: my game feels laggy?

Post by Marcus Aseth »

@bartbes Thanks, I think I can fix it now :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 141 guests