screen flickering


I was about to make another small game this time roguelite where the character moves in camera by 8px on screen. But is stays always at the center 64x64 of the window no matter what.

So i made the usual player movement by 8px at key press when all of sudden i spot that the screen is drawing a shadow in one frame and then another shadow in second frame is on other position moved by 8px from my old position. What the heck.

It seemed all my games that move the screen are having this problem as some kind of stuttering. I had vsync set to 1. And when on 0 the stuttering faded to normal values. But still this caused the cpu to overheat because all the cpu is now used in draw and update even when not moving.

So i added a love.timer.sleep(0.0016) to the love.update at the end. And it seems all is alright now. Maybe this helps someone else.

I suspect that the flickering is caused by lates update to 11.5 from 11.3… but im not sure. There is also a problem called double buffering but i can not seem to be able to turn it off. And theoretically i do not draw two frames with the position of player in the middle is not changing at all. So what else i miss?

Maybe i will find out soon.


Ok i fixed this by simply changing the draw method of camera_game so it calculates the position followed sprite in draw instead in update. This is because the draw runs more often than the update. Also i changed the calculation even in parallax image object and added vsync = 0 and in game.update Timer.sleep(0.016) which is 1/60 frame so it does not heat up the cpu on my laptop due to max frames per second not being limited by vsync = 1.

So far it seems the weird lagging behind was fixed and the parallax scrolling looks better.

Leave a comment

Log in with itch.io to leave a comment.