🐍 Python & Pygame: The Game Loop

Every game ever built β€” Pong, Minecraft, whatever you make next β€” runs on the same three-beat loop: INPUT β†’ UPDATE β†’ RENDER. This is that loop in real Pygame code, running live. Use ← β†’ (or the buttons) to catch the ball.

SCORE 0 60 FPS
Slow Motion runs the exact same loop 2 times per second β€” watch each phase light up in the code, one beat at a time.
catch.py β€” running live on the left

⏱ Frame Rate Lab β€” what breaks when FPS drops?

πŸš€
At 60 FPS both versions look identical. Now drop to 10 FPS and compare the two movement modes…

πŸ“¦ AABB Collision β€” drag the boxes together

player
coin
a.right > b.left
a.left < b.right
a.bottom > b.top
a.top < b.bottom
player.colliderect(coin) β†’ False