I know that a good way to achieve this is to multiply everything that is being updated each frame by a delta_time.
One example of that is here:
1 | cooldown += 5 * dt; |
I understand that the dt makes it framerate indepedent because it is inversely proportional to how much fps I am running at.
But look at this piece of code for example:
1 2 | particle->velocity += particle->acceleration * dt; particle->pos += particle->velocity * dt; |
I've tested it multiple times and it appears to work perfectly in different framerates, but why? I mean, it looks like I'm multiplying velocity by dt squared, and that shouldn't work to my knowledge. Isn't this a problem? If not, then why?
EDIT: Nevermind, I'm multiplying position by acceleration * dt², which makes sense since that is exactly how physics works.