Quick answer: flip() for full-screen + vsync. update(dirty_rects) for partial-screen UI. Don’t mix.
UI game stutters at 60fps. Each frame redraws everything via flip when only inventory changed. update with dirty rects is the fix.
The Fix
# Full screen redraw
screen.fill((0,0,0))
draw_world()
pygame.display.flip()
# Partial: dirty rect optimization
dirty = []
for sprite in changed_sprites:
rect = sprite.draw(screen)
dirty.append(rect)
pygame.display.update(dirty)
Track which rectangles changed; update only those. Static background untouched.
Verifying
UI scene goes from 30fps to 60fps with dirty rect approach. Profile per-frame draw time.
“flip for whole. update for parts.”
Related Issues
For Clock.tick busy_loop, see tick busy. For HiDPI text, see HiDPI.
Dirty rects. Update only changed.