Question about timer (SOLVED)

A) Because of floating point precision.

B) Because your ‘dt’ may not be exactly 1/60th of a second every frame. (Or 1/30th, 1/20th, etc.)

Your self.timer will never exactly equal 3. It may be 3.0000001. It may go from 2.985333 on one frame, to 3.00199966666667 on the next, skipping over 3.

Whenever you’re dealing with decimal numbers, you should use >= or <=.

2 Likes