Different principle of physics working with the same code

You would do it here:

position = position + self.velocity * dt

Multiplying by dt changes the logic from “add this amount of velocity per frame” to “add this amount of velocity per second”.

You’re maybe confused by this line:

self.velocity.y = self.velocity.y - GRAVITY * dt

That one is fine because it says “reduce y velocity by this amount of gravity per second”.

Multiplying self.velocity.x by dt is meaningless.

2 Likes