1
votes

I am developing a single player 2d game. The engine I use is my own. I was confused of how to adapt a game for different FPS. I would like to see identical game speed regardless of the quantity of frames a computer can work with. I mean if your computer is strong enough to paint 1000 times per second or it's only 20 frames, your game speed should be the same.

I've tried to automatically change moving parameters depending of FPS, but it seems to be impossible to connect that.

Actually, I have some decisions for that, but they are not ideal:

The first one is to limit FPS to 30 (for ex.), so, even a computer with a bad performance could show game correctly. - It's quite simple decision, but the smoothness of motion isn't the best.

The second one: game loop (and ,therefore, all the calculations) goes at a maximum frequency (60 FPS), but the screen is painted at a certain rate depending on the computer performance. - In this case RAM is more heavily loaded.

1
I suggested to do math based on elapsed time (indepently of framerate)Joan Esteban

1 Answers

0
votes

Framerate-independant with delta time (time passed since last render) is the solution.

Here is a detailed article about delta time with lots of code examples: https://isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timing I don't think you would need to go as deep into the solution as the article describes.

Here is an explanation of the concept: https://www.reddit.com/r/pcmasterrace/comments/29qcqr/an_explanation_of_game_loops_fps_and_delta_time/