Quick answer: Pygame Clock.tick() returning 0 ms for the first call? It hasn’t measured an interval yet — first call sets the baseline, returns 0 or near-0.
A delta-time-based animation starts with one frame of zero motion because tick returned 0 the first time.
First Tick Is Baseline
Internally, Clock stores the time of the last tick. First call has nothing to compare against; returns near 0. Subsequent calls return the elapsed ms since previous tick.
Warm Up
clock = pygame.time.Clock()
clock.tick() # warm-up, ignored
while running:
dt = clock.tick(60) / 1000.0Discard the first tick’s return. Loop’s first useful dt is from the second call.
Clamp Minimum
For robustness, treat any zero or sub-millisecond dt as a small positive minimum. Avoids divide-by-zero in physics integration.
get_time vs tick
Clock.get_time() returns ms since the previous tick without advancing. Useful when you tick once and read elapsed multiple times.
Verifying
First frame motion is sensible, not zero. No physics glitches from divide-by-zero on dt.
“First tick is baseline. Warm with a discarded tick or clamp.”
Wrap initialization in a tiny ‘prime the clock’ helper — you call it once at startup, no callers ever debug the first-frame zero again.