G
G
German2019-02-12 22:49:12
C++ / C#
German, 2019-02-12 22:49:12

How to set fixed draw speed and world steps in Box2D and SFML?

There is a simple project, Box2D does physics, SFML draws. On different machines with different performance, the speed of the program varies. How to set fixed speed? So what would the speed of the program (movement of objects) be the same on a powerful, medium and weak computer?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Moseychuk, 2019-02-13
@fshp

Start a timer and calculate the time difference between frames. From this difference you are already repelled.

W
Warlodya, 2019-02-13
@Warlodya

Try to read these two articles and change the world->step call
https://gafferongames.com/post/fix_your_timestep/
www.iforce2d.net/b2dtut/worlds

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question